* (bug 3019) use the operating system's random number generator if possible
when generating the qkey file
This commit is contained in:
1 parent
8801b06a1e
commit
c6249fcc25
7 files changed
+65
-9
No files matched your search
@@ -3217,3 +3217,24 @@ void Field_AutoComplete( field_t *field )
|
||||
|
||||
Field_CompleteCommand( completionField->buffer, qtrue, qtrue );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Com_RandomBytes
|
||||
|
||||
fills string array with len radom bytes, peferably from the OS randomizer
|
||||
==================
|
||||
*/
|
||||
void Com_RandomBytes( byte *string, int len )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( Sys_RandomBytes( string, len ) )
|
||||
return;
|
||||
|
||||
Com_Printf( "Com_RandomBytes: using weak randomization\n" );
|
||||
srand( time( 0 ) );
|
||||
for( i = 0; i < len; i++ )
|
||||
string[i] = (unsigned char)( rand() % 255 );
|
||||
}
|
||||
|
||||
+2
-2
@@ -263,7 +263,7 @@ char *Com_MD5File( const char *fn, int length, const char *prefix, int prefix_le
|
||||
unsigned char digest[16] = {""};
|
||||
fileHandle_t f;
|
||||
MD5_CTX md5;
|
||||
char buffer[2048];
|
||||
byte buffer[2048];
|
||||
int i;
|
||||
int filelen = 0;
|
||||
int r = 0;
|
||||
@@ -296,7 +296,7 @@ char *Com_MD5File( const char *fn, int length, const char *prefix, int prefix_le
|
||||
if(r + total > length)
|
||||
r = length - total;
|
||||
total += r;
|
||||
MD5Update(&md5 , (unsigned char *)buffer, r);
|
||||
MD5Update(&md5 , buffer, r);
|
||||
if(r < sizeof(buffer) || total >= length)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -640,6 +640,8 @@ void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...) __attribute_
|
||||
char *Com_SkipTokens( char *s, int numTokens, char *sep );
|
||||
char *Com_SkipCharset( char *s, char *sep );
|
||||
|
||||
void Com_RandomBytes( byte *string, int len );
|
||||
|
||||
// mode parm for FS_FOpenFile
|
||||
typedef enum {
|
||||
FS_READ,
|
||||
|
||||
@@ -1001,6 +1001,8 @@ int Sys_Milliseconds (void);
|
||||
|
||||
void Sys_SnapVector( float *v );
|
||||
|
||||
qboolean Sys_RandomBytes( byte *string, int len );
|
||||
|
||||
// the system console is shown when a dedicated server is running
|
||||
void Sys_DisplaySystemConsole( qboolean show );
|
||||
|
||||
|
||||
Reference in new issue
Block a user