Unverified Commit d3905419 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

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
parent 7f5e5706
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -1228,8 +1228,13 @@ curl_mime *curl_mime_init(struct Curl_easy *easy)
    }
    }


    memset(mime->boundary, '-', 24);
    memset(mime->boundary, '-', 24);
    Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24,
    if(Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24,
                  MIME_RAND_BOUNDARY_CHARS + 1);
                     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);
    mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL);
  }
  }