You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caball009
added
Minor
Severity: Minor < Major < Critical < Blocker
Gen
Relates to Generals
ZH
Relates to Zero Hour
Fix
Is fixing something, but is not user facing
NoRetail
This fix or change is not applicable with Retail game compatibility
labels
Apr 29, 2026
This PR fixes an out-of-bounds array access bug in AIUpdateInterface::xfer() where m_guardTargetType (a 2-element array) was xfer'd with sizeof(m_guardTargetType) starting at index [1], effectively reading into index [2] which is OOB and aliased to the first bytes of m_locationToGuard. The fix bumps the xfer version to 5 (unless RETAIL_COMPATIBLE_CRC/RETAIL_COMPATIBLE_XFER_SAVE is set) and adds a backward-compatibility path that faithfully reproduces the original byte layout when loading version < 5 saves.
Confidence Score: 5/5
Safe to merge — the fix is correct, the backward-compat path faithfully reproduces the original byte layout, and a static_assert guards the size assumption.
No P0 or P1 issues found. The out-of-bounds fix and version bump are correctly implemented in both the Generals and GeneralsMD codebases. The backward-compatibility path accurately accounts for all four element-widths written by the original buggy code, and xferCoord3D below the compat block correctly overwrites the partial m_locationToGuard data on load.
Bumps xfer version to 5 and replaces two buggy xferUser calls with a correct single call; adds backward-compat path that reproduces the original [0],[1],[1],[2]-equivalent byte layout for version < 5 saves.
This is currently the case which the makes change correct, but the point of this PR is to make it work even if we were to break this assertion in the future.
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
FixIs fixing something, but is not user facingGenRelates to GeneralsMinorSeverity: Minor < Major < Critical < BlockerNoRetailThis fix or change is not applicable with Retail game compatibilityZHRelates to Zero Hour
3 participants
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.
Original EA code links
https://github.com/electronicarts/CnC_Generals_Zero_Hour/blob/0a05454d8574207440a5fb15241b98ad0b435590/Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h#L679-L680
https://github.com/electronicarts/CnC_Generals_Zero_Hour/blob/0a05454d8574207440a5fb15241b98ad0b435590/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp#L4760-L4761
https://github.com/electronicarts/CnC_Generals_Zero_Hour/blob/0a05454d8574207440a5fb15241b98ad0b435590/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h#L697-L698
https://github.com/electronicarts/CnC_Generals_Zero_Hour/blob/0a05454d8574207440a5fb15241b98ad0b435590/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp#L5039-L5040
GeneralsGameCode/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h
Lines 700 to 701 in ffac8f9
GeneralsGameCode/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
Lines 5081 to 5082 in ffac8f9
The above code xfers
m_guardTargetTypeindices [0], [1], [1], [2], which is out-of-bounds. This PR fixes that.Edit: FWIW this equals true:
TODO: