Repository navigation
OpenDDL: check for the end of the buffer before reading in the token helpers - #6918
Mohil-Ahuja wants to merge 2 commits into
Conversation
…helpers isNotEndOfToken and isFloat dereferenced the position before comparing it with the end, and parseProperty read the first character of a value that might not be there, so a file ending inside a property read one byte past the buffer. The literal and comment helpers had the same pattern, and isReference read two bytes ahead before checking the end. Assisted-by: Claude Code
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The parser changes guard the targeted end-of-input reads, and the regression test exercises incomplete property values. No actionable risk introduced by this PR remains; it is mergeable after normal checks. Pre-merge checks |
|
parseProperty kept the identifier only when a value or reference followed the '='. An empty value left it unowned, which the test for a file ending after the '=' exposed under LeakSanitizer. Assisted-by: Claude Code
|
|
Openddl is a separate component. Please send your PR upstream to https://github.com/kimkulling/openddl-parser |
|
Thanks @turol. Upstream already has these fixes in an open PR: kimkulling/openddl-parser#98 (open since 16 Sep). It adds the same end-of-buffer checks to Once #98 is merged and contrib/openddlparser is synced, this PR isn't needed and I'll close it. The OpenGEX test here ( |
|
Make a separate PR of the unit test. |
|
Done: the test is in #6934, with a note that the AddressSanitizer job will flag it until contrib/openddlparser is synced with kimkulling/openddl-parser#98. |



Several token helpers in
OpenDDLParserUtils.hread*inbefore comparinginwithend:isNotEndOfTokencheckedin != endlast, soisIntegerandisFloatread one byte past the buffer when a value ran to the end of the fileisFloattested for the.after its digit loop without checking for the endparsePropertypassed*intoisStringLiteralwhen the value was emptyisHexLiteral,isComment,isCommentOpenTagandisCommentCloseTagread their first character unchecked, andisReferenceread two bytes ahead before checking the endEach now checks the end before reading.
parsePropertyalso left the property name unowned when the value was empty, which the new test exposed under LeakSanitizer, so it now frees the name whenever no property takes it.New test
utOpenGEXImportExport.importPropertyAtEndOfFileNoCrashimportsMetric (key =andMetric (key = -, which end right after a property's=and inside a number.Found with
assimp_postprocess_fuzzerandassimp_fuzzer_ifc(the OpenGEX importer picks up the files). Under ASan:heap-buffer-overflowREAD inisNotEndOfToken,isFloatandparseProperty, for the new test and for the fuzzer inputs that hit themSummary by CodeRabbit