From 3c8b1b98a3af74a83850f8f03a11e56954437a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= Date: Wed, 28 Aug 2024 10:52:51 -0400 Subject: [PATCH] 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. --- util.c | 5 +++++ 1 file changed, 5 insertions(+) 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)){