mirror of
https://github.com/curl/curl.git
synced 2026-08-04 10:40:06 +03:00
Curl_rand: fixed and moved to rand.c
Now Curl_rand() is made to fail if it cannot get the necessary random level. Changed the proto of Curl_rand() slightly to provide a number of ints at once. Moved out from vtls, since it isn't a TLS function and vtls provides Curl_ssl_random() for this to use. Discussion: https://curl.haxx.se/mail/lib-2016-11/0119.html
This commit is contained in:
parent
050aa80309
commit
f682156a4f
10 changed files with 211 additions and 98 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#include "strcase.h"
|
||||
#include "sendf.h"
|
||||
#include "strdup.h"
|
||||
#include "rand.h"
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
#include "curl_memory.h"
|
||||
|
|
@ -1569,8 +1570,12 @@ static char *formboundary(struct Curl_easy *data)
|
|||
{
|
||||
/* 24 dashes and 16 hexadecimal digits makes 64 bit (18446744073709551615)
|
||||
combinations */
|
||||
return aprintf("------------------------%08x%08x",
|
||||
Curl_rand(data), Curl_rand(data));
|
||||
unsigned int rnd[2];
|
||||
CURLcode result = Curl_rand(data, &rnd[0], 2);
|
||||
if(result)
|
||||
return NULL;
|
||||
|
||||
return aprintf("------------------------%08x%08x", rnd[0], rnd[1]);
|
||||
}
|
||||
|
||||
#else /* CURL_DISABLE_HTTP */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue