summaryrefslogtreecommitdiffstats
path: root/lib/rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rand.c')
-rw-r--r--lib/rand.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/rand.c b/lib/rand.c
index 3383c49..c62b1a4 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -201,7 +201,7 @@ CURLcode Curl_rand(struct Curl_easy *data, unsigned char *rnd, size_t num)
{
CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
- DEBUGASSERT(num > 0);
+ DEBUGASSERT(num);
while(num) {
unsigned int r;
@@ -241,9 +241,11 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
memset(buffer, 0, sizeof(buffer));
#endif
- if((num/2 >= sizeof(buffer)) || !(num&1))
+ if((num/2 >= sizeof(buffer)) || !(num&1)) {
/* make sure it fits in the local buffer and that it is an odd number! */
+ DEBUGF(infof(data, "invalid buffer size with Curl_rand_hex"));
return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
num--; /* save one for null-termination */