From 9c59e24d337406ca0b5cc3b42cd57c26c1790276 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Tue, 23 Feb 2021 22:07:20 -0500 Subject: [PATCH] Ensure that real_getrandom is initialized properly This avoids potential failure if another library calls getrandom() within its constructor before we are loaded. For me, it lets "make randomtest" succeed in tests/ Closes: #295 --- src/libfaketime.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libfaketime.c b/src/libfaketime.c index a09bae2..4392791 100644 --- a/src/libfaketime.c +++ b/src/libfaketime.c @@ -3684,6 +3684,10 @@ ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) { return buflen; } else { /* if no FAKERANDOM_SEED was given, use the original function */ + if (!initialized) + { + ftpl_init(); + } return real_getrandom(buf, buflen, flags); } }