diff options
author | tjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2007-02-16 23:50:37 +0000 |
---|---|---|
committer | tjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2007-02-16 23:50:37 +0000 |
commit | 9dbe35a4dd8d5fce96c627f000d15395f32bc55a (patch) | |
tree | 3bc0f6b9f85125a426cdc2a290237adc76b1c699 /code/unix | |
parent | 9a51af746dd98abd8ca52424a4b78a16e3d98b7b (diff) | |
download | ioquake3-aero-9dbe35a4dd8d5fce96c627f000d15395f32bc55a.tar.gz ioquake3-aero-9dbe35a4dd8d5fce96c627f000d15395f32bc55a.zip |
* (bug 3019) use the operating system's random number generator if possible
when generating the qkey file
git-svn-id: svn://svn.icculus.org/quake3/trunk@1046 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/unix')
-rw-r--r-- | code/unix/unix_shared.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/code/unix/unix_shared.c b/code/unix/unix_shared.c index c037813..a607a2f 100644 --- a/code/unix/unix_shared.c +++ b/code/unix/unix_shared.c @@ -174,6 +174,22 @@ char *strlwr (char *s) { return s; // bk001204 - duh } +qboolean Sys_RandomBytes( byte *string, int len ) +{ + FILE *fp; + + fp = fopen( "/dev/urandom", "r" ); + if( !fp ) + return qfalse; + + if( !fread( string, sizeof( byte ), len, fp ) ) { + fclose( fp ); + return qfalse; + } + fclose( fp ); + return qtrue; +} + //============================================ #define MAX_FOUND_FILES 0x1000 |