From cddef0c0be1c30f45ea525af7a42b54d1a78786c Mon Sep 17 00:00:00 2001 From: Don Viszneki Date: Mon, 5 Mar 2018 18:43:31 -0800 Subject: [PATCH] tests: add warning message when /dev/urandom fails in case this code should ever be used as an example, a warning is a nice way of helping ensure insecure keys are not generated --- src/tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests.c b/src/tests.c index 893d29722c0e2..05314572c0f91 100644 --- a/src/tests.c +++ b/src/tests.c @@ -4919,6 +4919,7 @@ int main(int argc, char **argv) { } else { FILE *frand = fopen("/dev/urandom", "r"); if ((frand == NULL) || fread(&seed16, sizeof(seed16), 1, frand) != sizeof(seed16)) { + fprintf(stderr, "WARNING: could not read 16 bytes from /dev/urandom; falling back to insecure PRNG\n"); uint64_t t = time(NULL) * (uint64_t)1337; seed16[0] ^= t; seed16[1] ^= t >> 8;