]> granicus.if.org Git - curl/commitdiff
mime: check Curl_rand_hex's return code
authorDaniel Stenberg <daniel@haxx.se>
Thu, 26 Jul 2018 13:55:59 +0000 (16:55 +0300)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 28 Jul 2018 20:36:15 +0000 (22:36 +0200)
Bug: https://curl.haxx.se/mail/archive-2018-07/0015.html
Reported-by: Jeffrey Walton
Closes #2795

lib/mime.c

index fd7beb9a4e523703d8bcd561100c6b44865a3e3b..ca492d11ae984365be507a1d3fb4fba03f858cf4 100644 (file)
@@ -1228,8 +1228,13 @@ curl_mime *curl_mime_init(struct Curl_easy *easy)
     }
 
     memset(mime->boundary, '-', 24);
-    Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24,
-                  MIME_RAND_BOUNDARY_CHARS + 1);
+    if(Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24,
+                     MIME_RAND_BOUNDARY_CHARS + 1)) {
+      /* failed to get random separator, bail out */
+      free(mime->boundary);
+      free(mime);
+      return NULL;
+    }
     mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL);
   }