[HL25] Backport index out of bounds fixes
This commit is contained in:
parent
91ea9ed318
commit
e880a9da6f
2 changed files with 27 additions and 0 deletions
|
@ -662,6 +662,27 @@ bool CHudAmmo::MsgFunc_WeaponList(const char* pszName, int iSize, void* pbuf)
|
|||
Weapon.iFlags = READ_BYTE();
|
||||
Weapon.iClip = 0;
|
||||
|
||||
if (Weapon.iId < 0 || Weapon.iId >= MAX_WEAPONS)
|
||||
return 0;
|
||||
|
||||
if (Weapon.iSlot < 0 || Weapon.iSlot >= MAX_WEAPON_SLOTS + 1)
|
||||
return 0;
|
||||
|
||||
if (Weapon.iSlotPos < 0 || Weapon.iSlotPos >= MAX_WEAPON_POSITIONS + 1)
|
||||
return 0;
|
||||
|
||||
if (Weapon.iAmmoType < -1 || Weapon.iAmmoType >= MAX_AMMO_TYPES)
|
||||
return 0;
|
||||
|
||||
if (Weapon.iAmmo2Type < -1 || Weapon.iAmmo2Type >= MAX_AMMO_TYPES)
|
||||
return 0;
|
||||
|
||||
if (Weapon.iAmmoType >= 0 && Weapon.iMax1 == 0)
|
||||
return 0;
|
||||
|
||||
if (Weapon.iAmmo2Type >= 0 && Weapon.iMax2 == 0)
|
||||
return 0;
|
||||
|
||||
gWR.AddWeapon(&Weapon);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -153,6 +153,12 @@ public:
|
|||
for( int i=0; i<count; ++i )
|
||||
{
|
||||
file->Read( &len, sizeof(unsigned short) );
|
||||
if ( len >= sizeof( placeName ) )
|
||||
{
|
||||
assert( false && "PlaceDirectory::Load: Invalid placeName size" );
|
||||
return;
|
||||
}
|
||||
|
||||
file->Read( placeName, len );
|
||||
placeName[ sizeof( placeName ) - 1 ] = '\0';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue