From 2917077323ac469ea12bfe4161a4f9e2082e652a Mon Sep 17 00:00:00 2001 From: Dion Williams Date: Mon, 7 Sep 2015 11:32:43 +0100 Subject: [PATCH] Ensure reads from /dev/urandom are unbuffered Upstream: JACoders/OpenJK@de6a9dfd40065ae9a5a2b0b3ef701feee8dac867 --- code/sys/sys_unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c index 0cffd4f1..60050931 100644 --- a/code/sys/sys_unix.c +++ b/code/sys/sys_unix.c @@ -123,6 +123,8 @@ qboolean Sys_RandomBytes( byte *string, int len ) if( !fp ) return qfalse; + setvbuf( fp, NULL, _IONBF, 0 ); // don't buffer reads from /dev/urandom + if( fread( string, sizeof( byte ), len, fp ) != len ) { fclose( fp );