From: Cristian Rodríguez Date: Wed, 28 Aug 2024 14:52:51 +0000 (-0400) Subject: If RNG is already seeded, return early X-Git-Tag: 1.9.0-rc.1~13^2~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c8b1b98a3af74a83850f8f03a11e56954437a2f;p=thirdparty%2Fldns.git If RNG is already seeded, return early Most of the time, in most systems the openSSL RNG seeds itself automatically, in that case rand status returns 1, this is sufficient to return early. --- diff --git a/util.c b/util.c index 662aa23a..83d31f70 100644 --- a/util.c +++ b/util.c @@ -346,6 +346,11 @@ ldns_init_random(FILE *fd, unsigned int size) unsigned int seed_i; struct timeval tv; +#ifdef HAVE_SSL + if(RAND_status() == 1) + /* already seeded */ + return 0; +#endif /* we'll need at least sizeof(unsigned int) bytes for the standard prng seed */ if (size < (unsigned int) sizeof(seed_i)){