engine: fix some ubsan warnings (alignment, integer limits...)
This commit is contained in:
parent
e81a0ded11
commit
e7564420c9
2 changed files with 6 additions and 6 deletions
|
@ -1048,7 +1048,7 @@ static void CL_GetCDKey( char *protinfo, size_t protinfosize )
|
|||
char key[64];
|
||||
int keylength;
|
||||
|
||||
keylength = Q_snprintf( key, sizeof( key ), "%u", COM_RandomLong( 0, 0x7fffffff ));
|
||||
keylength = Q_snprintf( key, sizeof( key ), "%u", COM_RandomLong( 0, 0x7ffffffe ));
|
||||
|
||||
MD5Init( &ctx );
|
||||
MD5Update( &ctx, key, keylength );
|
||||
|
|
|
@ -33,7 +33,7 @@ static const byte mungify_table3[] =
|
|||
0x0A, 0x2D, 0x48, 0x0C, 0x4A, 0x12, 0xA9, 0xB5,
|
||||
};
|
||||
|
||||
static int COM_SwapLong( int c )
|
||||
static uint COM_SwapLong( uint c )
|
||||
{
|
||||
return ((( c >> 0 ) & 0xFF) << 24 ) +
|
||||
((( c >> 8 ) & 0xFF) << 16 ) +
|
||||
|
@ -48,12 +48,12 @@ static void COM_GenericMunge( byte *data, const size_t len, const int seq, const
|
|||
|
||||
for( i = 0; i < mungelen; i++ )
|
||||
{
|
||||
uint *pc, c;
|
||||
uint32_t c;
|
||||
void *pc = &data[i * 4];
|
||||
byte *p;
|
||||
int j;
|
||||
|
||||
pc = (uint *)&data[i * 4];
|
||||
c = *pc;
|
||||
memcpy( &c, pc, sizeof( c ));
|
||||
c ^= seq;
|
||||
if( !reverse )
|
||||
c = COM_SwapLong( c );
|
||||
|
@ -65,7 +65,7 @@ static void COM_GenericMunge( byte *data, const size_t len, const int seq, const
|
|||
if( reverse )
|
||||
c = COM_SwapLong( c );
|
||||
c ^= ~seq;
|
||||
*pc = c;
|
||||
memcpy( pc, &c, sizeof( c ));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue