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.
The code shown below expects
weaponowned[]to be an array of integers:DOOM/linuxdoom-1.10/st_stuff.c
Lines 1316 to 1324 in a77dfb9
However,
weaponowned[]is defined asboolean. No big deal if we assumebooleanor a type ofenumis the same size as aninteger, until you hit the code shown below and nowbooleancan be defined asbool.DOOM/linuxdoom-1.10/doomtype.h
Lines 28 to 37 in a77dfb9
If
booleanis now defined asbool, which is compiler specific, but most of the time is an 8-bit byte, the first snippet of code above is now accessing 2- or 4-byte integers instead of 1-byte bools.When this is the case, when
ibecomes an index high enough to overflow the memory allocated forweaponowned[], a value other than 0 and 1 will be used.Here are a few possibilities when
boolis defined as a 1-bytechar:65536 (0x00010000), or a number of other combinations.
iindex gets large enough to overflow the 9-byteweaponowned[]buffer, the values now become arbitrary and can be any value, really.(int *) &plyr->weaponowned[i+1]will access at 2- or 4-byte increments, a small value iniwill soon overflow the buffer.The latter three scenarios can and probably will cause a Page Fault Exception, depending on your system, if at the very least not return the value you need.
Simply changing
booleantointbelow should make sure this doesn't happen.DOOM/linuxdoom-1.10/d_player.h
Line 119 in a77dfb9