fix(gta-core-five): bound-check scenario point ped model set index - #4124
Open
DaniGP17 wants to merge 1 commit into
Open
fix(gta-core-five): bound-check scenario point ped model set index#4124DaniGP17 wants to merge 1 commit into
DaniGP17 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal of this PR
CScenarioPoint::GetModelSetIndex()indexes m_ModelSets[kVehicleModelSets] for vehicle scenario points and m_ModelSets[kPedModelSets] for everything else, with no bounds check. Two call sites use it as a ped index without guarding on the scenario type, so a streamed AMBIENT_VEHICLE_MODEL_SET_FILE that grows the vehicle set count past the ped set count turns the mismatch into an OOB read.Also fixes
CAmbientModelSets::Append()nulling every model's Variations right after adopting it, which made resources streaming vehiclemodelsets.meta spawn the correct vehicle but always stock (mods/colours/livery never apply).Used this resource for testing: https://github.com/lkid73/sete_le
How is this PR achieving the goal
Bound-checks
CScenarioPoint::GetModelSetIndex()before it's used as a ped model set index, fixing an OOB read crash when a resource streams enough vehicle model sets to overflow the ped array.Removes a ReleaseVariations() call in CAmbientModelSets::Append() that was nulling vehicle mods/colours/livery on load, so streamed vehicle model sets stopped spawning stock.
This PR applies to the following area(s)
FiveM
Successfully tested on
Game builds: 3407
Platforms: Windows
Checklist
Fixes issues
fixes #3473