Repository navigation
fix(weaponset): Add sanity check for weapon slot index in WeaponSet::setWeaponLock() - #3529
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughBoth game variants now check that a weapon slot is within the weapon array before ChangesWeapon lock slot validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
[Medium impact] The PR appears safe to merge.
|
| if (static_cast<UnsignedInt>(weaponSlot) >= ARRAY_SIZE(m_weapons)) | ||
| { | ||
| // TheSuperHackers @fix Don't process commands with an invalid weaponslot. | ||
| return false; |
There was a problem hiding this comment.
Is a DEBUG_CRASH maybe warranted here?
There was a problem hiding this comment.
I don't mind adding it, but I don't see the value myself.
There was a problem hiding this comment.
It can help warn of invalid data?
What is the value of the warning? Is there an action we could or should take if we know that this code was executed?
There was a problem hiding this comment.
i was just considering if there was the possibility of invalid ini data getting this far, but it likely doesn't.
You could also simplify this to weaponSlot >= WEAPONSLOT_COUNT
There was a problem hiding this comment.
i was just considering if there was the possibility of invalid ini data getting this far, but it likely doesn't.
Not that I'm aware of.
You could also simplify this to
weaponSlot >= WEAPONSLOT_COUNT
This doesn't catch negative numbers (WeaponSlotType's underlying type is signed). It also requires you to look up that ARRAY_SIZE(m_weapons) == WEAPONSLOT_COUNT.
There was a problem hiding this comment.
most of the code already uses WEAPONSLOT_COUNT in this context, but it is also fair on the unsigned side of it.
b234b3e to
4883006
Compare
The following
GameMessagetypes read a weapon slot index from the game messages:There's currently no sanity check on the value, so it may be modified to go to cause the game access out-of-bounds data and cause a crash. This PR adds a sanity check before the weapon slot value is used.