Ensure reads from /dev/urandom are unbuffered

Upstream: JACoders/OpenJK@de6a9dfd40
This commit is contained in:
Dion Williams 2015-09-07 11:32:43 +01:00
parent 87e0bf6eaf
commit 2917077323
1 changed files with 2 additions and 0 deletions

View File

@ -123,6 +123,8 @@ qboolean Sys_RandomBytes( byte *string, int len )
if( !fp ) if( !fp )
return qfalse; return qfalse;
setvbuf( fp, NULL, _IONBF, 0 ); // don't buffer reads from /dev/urandom
if( fread( string, sizeof( byte ), len, fp ) != len ) if( fread( string, sizeof( byte ), len, fp ) != len )
{ {
fclose( fp ); fclose( fp );