TobyLobster / Inform

Inform is a design system for interactive fiction based on natural language
Other
82 stars 18 forks source link

Heap buffer overflow in [IFSyntaxData styleAtEndOfLine:] #39

Closed angstsmurf closed 1 year ago

angstsmurf commented 1 year ago

Running with AddressSanitizer on, pressing enter at the end of the source text will crash with a heap buffer overflow here: https://github.com/TobyLobster/Inform/blob/c704aa7191cdc6e4c949a8e25df65a415846c704/inform/Project/Syntax/IFSyntaxData.m#L1603 In my case, the pos variable was set to 58 while charStyles had the range 0 … 57, so return charStyles[pos]; was reading 1 past the end.

charStyles was realloc'd to size 58 here: https://github.com/TobyLobster/Inform/blob/c704aa7191cdc6e4c949a8e25df65a415846c704/inform/Project/Syntax/IFSyntaxData.m#L799

TobyLobster commented 1 year ago

Thanks, should be fixed now.