cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Calls to srand() in Curl_FormBoundary()

From: Patrick Monnerat <Patrick.Monnerat_at_datasphere.ch>
Date: Fri, 12 Jun 2009 19:16:22 +0200

 
Patrick Monnerat wrote:

(I like to answer to my own message ;-)
>> Wouldn't it be good enough to move the srand() call to the
curl_global_init() function?

> We could also have our own random number generator, with our own
random seed, in order to not interfere with the standard one. In fact,
some randomization is desirable for a form boundary, but the effective
number suite is not so important.

Here is a patch that provides a sufficiently good random number sequence
without using rand()/srand(). In addition, it is seeded only once in
curl_global_init(): this is even better than reseeding it (even with
adding an incremental value) each time we need a new boundary.

Just tell if you want I commit...

Good week-end to all of you
Patrick

Received on 2009-06-12