[iortcw] 392/497: All: Ensure reads from /dev/urandom are unbuffered

Simon McVittie smcv at debian.org
Fri Sep 8 10:37:34 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 43e76dddc0ae93c7164016ce359a51306d6f6c08
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Wed Sep 9 11:15:35 2015 -0400

    All: Ensure reads from /dev/urandom are unbuffered
---
 MP/code/sys/sys_unix.c | 2 ++
 SP/code/sys/sys_unix.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/MP/code/sys/sys_unix.c b/MP/code/sys/sys_unix.c
index e4bbc4a..62c95ee 100644
--- a/MP/code/sys/sys_unix.c
+++ b/MP/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 );
diff --git a/SP/code/sys/sys_unix.c b/SP/code/sys/sys_unix.c
index 84dc1ef..02286dd 100644
--- a/SP/code/sys/sys_unix.c
+++ b/SP/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 );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list