mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Use random() and srandom() if available.
Reported-by: Coverity scanner
This commit is contained in:
parent
18fe274e1c
commit
7a7a241e5b
@ -1,3 +1,7 @@
|
|||||||
|
2014-11-19 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||||
|
|
||||||
|
* configure.ac: Check for random()
|
||||||
|
|
||||||
2014-11-17 Tim Ruehsen <tim.ruehsen@gmx.de>
|
2014-11-17 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||||
|
|
||||||
* bootstrap.conf (gnulib_modules): Add module c-strcase
|
* bootstrap.conf (gnulib_modules): Add module c-strcase
|
||||||
|
@ -241,7 +241,7 @@ AC_FUNC_MMAP
|
|||||||
AC_FUNC_FSEEKO
|
AC_FUNC_FSEEKO
|
||||||
AC_CHECK_FUNCS(strptime timegm vsnprintf vasprintf drand48 pathconf)
|
AC_CHECK_FUNCS(strptime timegm vsnprintf vasprintf drand48 pathconf)
|
||||||
AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth mbtowc)
|
AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth mbtowc)
|
||||||
AC_CHECK_FUNCS(sleep symlink utime strlcpy)
|
AC_CHECK_FUNCS(sleep symlink utime strlcpy random)
|
||||||
|
|
||||||
if test x"$ENABLE_OPIE" = xyes; then
|
if test x"$ENABLE_OPIE" = xyes; then
|
||||||
AC_LIBOBJ([ftp-opie])
|
AC_LIBOBJ([ftp-opie])
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2014-11-19 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||||
|
|
||||||
|
* utils.c (random_float, random_number): Use random() and
|
||||||
|
srandom() if available.
|
||||||
|
|
||||||
|
Reported-by: Coverity scanner
|
||||||
|
|
||||||
2014-11-19 Tim Ruehsen <tim.ruehsen@gmx.de>
|
2014-11-19 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||||
|
|
||||||
* ftp-basic.c (ftp_epsv): Fix loop check
|
* ftp-basic.c (ftp_epsv): Fix loop check
|
||||||
|
13
src/utils.c
13
src/utils.c
@ -1846,7 +1846,14 @@ static int rnd_seeded;
|
|||||||
int
|
int
|
||||||
random_number (int max)
|
random_number (int max)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DRAND48
|
#ifdef HAVE_RANDOM
|
||||||
|
if (!rnd_seeded)
|
||||||
|
{
|
||||||
|
srandom ((long) time (NULL) ^ (long) getpid ());
|
||||||
|
rnd_seeded = 1;
|
||||||
|
}
|
||||||
|
return random () % max;
|
||||||
|
#elif defined HAVE_DRAND48
|
||||||
if (!rnd_seeded)
|
if (!rnd_seeded)
|
||||||
{
|
{
|
||||||
srand48 ((long) time (NULL) ^ (long) getpid ());
|
srand48 ((long) time (NULL) ^ (long) getpid ());
|
||||||
@ -1881,7 +1888,9 @@ random_number (int max)
|
|||||||
double
|
double
|
||||||
random_float (void)
|
random_float (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DRAND48
|
#ifdef HAVE_RANDOM
|
||||||
|
return ((double) random_number (RAND_MAX)) / RAND_MAX;
|
||||||
|
#elif defined HAVE_DRAND48
|
||||||
if (!rnd_seeded)
|
if (!rnd_seeded)
|
||||||
{
|
{
|
||||||
srand48 ((long) time (NULL) ^ (long) getpid ());
|
srand48 ((long) time (NULL) ^ (long) getpid ());
|
||||||
|
Loading…
Reference in New Issue
Block a user