forked from sezero/quakespasm
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix potential buffer overflow in COM_Parse
e.g. `wad` field longer than 1023 characters
- Loading branch information
1 parent
9497d57
commit 764ef9d
Showing
7 changed files
with
49 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
764ef9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sezero @j0zzz This issue is also present in QS and JoeQuake. It looks like newer versions of ericw-tools now allow fields longer than 1024 characters, which can overflow
com_token
used inCOM_Parse
.Small test BSP that can trigger this: parsecrash.zip.
764ef9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't make it to crash on i686-linux as is, but valgrind screamed
only after I changed com_token from an array to a malloc'ed pointer
Thanks. And to think that the issue was actually implied in another
bug report: sezero#25 - sigh..
Will push this shortly after adapting.
P.S.: Change to
COM_ParseStringNewline
is irrelevant as far as I cansee (and it is different in QS, using sscanf.)
764ef9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch applied to QS as sezero@584d3c6
764ef9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version of JoeQuake that I tested with didn't crash, either, but looking at the code, the issue is there as well. FWIW, the Win64 binary for QS 0.96.0 did crash.
Yup, not strictly relevant for this fix, but I wanted to remove the hardcoded 1023 in case the size of com_token is ever increased.
764ef9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does in debug. Not sure why it doesn't in release, maybe due to compilation options...?
Anyways, after applying the changes, it does properly load the map, but saving game still makes it crash. Looking the issue right now.
@andrei-drexler Thank you very much for the info about this patch.
764ef9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, found the issue with savegame, JoeQuake was missing this fix from QuakeSpasm:
sezero@15a41d2
764ef9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified that one: sezero@22e57e0