diff options
author | Steve Holme <steve_holme@hotmail.com> | 2014-06-08 20:33:29 +0100 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2014-06-11 21:13:40 +0100 |
commit | 51bb067a4289f5e4717391eb62f91465706b4ebc (patch) | |
tree | 1404473d751c03be60d84f8c21770ef5955292ea | |
parent | bde0d89c3d4a1fa284ad67299f43e5f2f7acad59 (diff) | |
download | curl-51bb067a4289f5e4717391eb62f91465706b4ebc.tar.gz |
Curl_rand: Use a fake entropy for debug builds when CURL_ENTROPY set
-rw-r--r-- | lib/vtls/vtls.c | 19 | ||||
-rwxr-xr-x | tests/runtests.pl | 1 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index ab7274ace..58295a4de 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -197,6 +197,23 @@ unsigned int Curl_rand(struct SessionHandle *data) static unsigned int randseed; static bool seeded = FALSE; +#ifdef CURLDEBUG + char *force_entropy = getenv("CURL_ENTROPY"); + if(force_entropy) { + if(!seeded) { + size_t elen = strlen(force_entropy); + size_t clen = sizeof(randseed); + size_t min = elen < clen ? elen : clen; + memcpy((char *)&randseed, force_entropy, min); + seeded = TRUE; + } + else + randseed++; + + return randseed; + } +#endif + #ifndef have_curlssl_random (void)data; #else diff --git a/tests/runtests.pl b/tests/runtests.pl index bf7aaeed1..5982348e9 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -311,6 +311,7 @@ if (!$USER) { # enable memory debugging if curl is compiled with it $ENV{'CURL_MEMDEBUG'} = $memdump; +$ENV{'CURL_ENTROPY'}="12345678"; $ENV{'HOME'}=$pwd; sub catch_zap { |