]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
If RNG is already seeded, return early 249/head
authorCristian Rodríguez <cristian@rodriguez.im>
Wed, 28 Aug 2024 14:52:51 +0000 (10:52 -0400)
committerCristian Rodríguez <cristian@rodriguez.im>
Wed, 28 Aug 2024 14:52:51 +0000 (10:52 -0400)
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

diff --git a/util.c b/util.c
index 662aa23a96d161394db205e04276e421eb0c399a..83d31f70eda04348d1c5073f080f07fc6f423130 100644 (file)
--- 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)){