From: Daniel Stenberg Date: Thu, 26 Jul 2018 13:55:59 +0000 (+0300) Subject: mime: check Curl_rand_hex's return code X-Git-Tag: curl-7_61_1~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d3905419444614463506243930be1648fb2d7aa7;p=thirdparty%2Fcurl.git mime: check Curl_rand_hex's return code Bug: https://curl.haxx.se/mail/archive-2018-07/0015.html Reported-by: Jeffrey Walton Closes #2795 --- diff --git a/lib/mime.c b/lib/mime.c index fd7beb9a4e..ca492d11ae 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -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); }