fixed demo playback crashing when delta entities/players had an invalid field count

This commit is contained in:
myT 2018-01-24 01:41:30 +01:00
parent 4fcf0f410e
commit eaa376a292
2 changed files with 8 additions and 0 deletions

View File

@ -10,6 +10,8 @@ chg: on Windows, a fatal error will move the early console window to the foregro
chg: com_hunkMegs doesn't have a maximum value anymore
a value too high would reset it and the engine might fail to load with the default value
fix: demo playback would crash when delta entities/players had an invalid field count
fix: strcpy calls with overlapping buffers (undefined behavior), which were responsible for the
"chars.h not found" / "couldn't load any skills" issue preventing bots from being added

View File

@ -789,6 +789,9 @@ void MSG_ReadDeltaEntity( msg_t* msg, const entityState_t* from, entityState_t*
}
lc = MSG_ReadByte(msg);
if ( lc < 0 || lc > ARRAY_LEN(entityStateFields) ) {
Com_Error( ERR_DROP, "invalid entityState_t field count %d (max: %d)\n", lc, ARRAY_LEN(entityStateFields) );
}
// shownet 2/3 will interleave with other printed info, -1 will
// just print the delta records
@ -1110,6 +1113,9 @@ void MSG_ReadDeltaPlayerstate( msg_t* msg, const playerState_t* from, playerStat
#endif
lc = MSG_ReadByte(msg);
if ( lc < 0 || lc > ARRAY_LEN(playerStateFields) ) {
Com_Error( ERR_DROP, "invalid playerState_t field count %d (max: %d)\n", lc, ARRAY_LEN(playerStateFields) );
}
const netField_t* field;
for ( i = 0, field = playerStateFields ; i < lc ; i++, field++ ) {