bugfix(network): Prevent buffer overflow in NetPacket::readFileMessage() and NetPacket::readFileAnnounceMessage()#1981
Merged
xezon merged 1 commit intoDec 13, 2025
Conversation
Caball009
reviewed
Dec 11, 2025
…e() and NetPacket::readFileAnnounceMessage() Co-authored-by: JBremer <jbremer@users.noreply.github.com> Co-authored-by: SkyAero <Skyaero42@users.noreply.github.com>
60516eb to
f101fdd
Compare
Author
|
Updated from feedback. |
|
Nice. Technically I think this still allows OOB reads when the input is not nul-terminated, but in practice I don't think that's an issue. Great work, thanks for making it slightly more secure ;-) |
fbraz3
pushed a commit
to fbraz3/GeneralsX
that referenced
this pull request
Feb 23, 2026
…e() and NetPacket::readFileAnnounceMessage() (TheSuperHackers#1981) Co-authored-by: JBremer <jbremer@users.noreply.github.com> Co-authored-by: SkyAero <Skyaero42@users.noreply.github.com>
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.
This is a continuation of an earlier orphaned PR
Closes: #1668
This PR fixes two possible buffer overflows in NetPacket file handling messages.
We are expecting the received message to be in a particular format and for strings received to be null terminated.
But the original code never checked if we had exceeded the size of the buffer in which the string will be stored.
The size of the buffer cannot be changed as it relates to the maximum path length supported within windows when long file paths are not in use.
Strlcpy will return the length of the orginal string beyond the size of the buffer but will only copy up to the buffer size-1, the rest of the code is safe from malicious behaviour but a malformed packet may cause unexpected behaviour still.