Validate player/item names coming from save file #7779
+36
−24
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.
When reviewing #7775, I noticed the code is just blindly assuming that
LoadHelper::NextBytes()
will produce a null-terminated string inItem::_iName
,Item::_iIName
andPlayer::_pName
, but the function provides no such guarantee.I was able to observe a buffer overrun with single_0.sv.zip, using some debug code to visualize it. The player name is completely full of the
s
character. The debug code writesi
characters into the item seed for the player's head slot so they can be seen in the output.Here's what that looks like when I press
x
four times.And to demonstrate how non-debug code makes the assumption about null termination, here is an example of that.