Skip to content

OpenDDL: check for the end of the buffer before reading in the token helpers - #6918

Closed
Mohil-Ahuja wants to merge 2 commits into
assimp:masterfrom
Mohil-Ahuja:openddl-token-end-check
Closed

Mohil-Ahuja wants to merge 2 commits into
assimp:masterfrom
Mohil-Ahuja:openddl-token-end-check

Conversation

@Mohil-Ahuja

@Mohil-Ahuja Mohil-Ahuja commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Several token helpers in OpenDDLParserUtils.h read *in before comparing in with end:

  • isNotEndOfToken checked in != end last, so isInteger and isFloat read one byte past the buffer when a value ran to the end of the file
  • isFloat tested for the . after its digit loop without checking for the end
  • parseProperty passed *in to isStringLiteral when the value was empty
  • isHexLiteral, isComment, isCommentOpenTag and isCommentCloseTag read their first character unchecked, and isReference read two bytes ahead before checking the end

Each now checks the end before reading. parseProperty also 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.importPropertyAtEndOfFileNoCrash imports Metric (key = and Metric (key = -, which end right after a property's = and inside a number.

Found with assimp_postprocess_fuzzer and assimp_fuzzer_ifc (the OpenGEX importer picks up the files). Under ASan:

  • before: heap-buffer-overflow READ in isNotEndOfToken, isFloat and parseProperty, for the new test and for the fuzzer inputs that hit them
  • after: none of those inputs crash, and the full unit suite passes (717 tests, with leak detection on)

Summary by CodeRabbit

  • Bug Fixes
    • Prevented crashes when parsing incomplete property values or encountering truncated tokens, references, numbers, and comments at the end of input. Inputs that end unexpectedly are now handled safely during parsing.
  • Tests
    • Added coverage for OpenGEX inputs that end with incomplete property values, including values that stop immediately after an equals sign or a minus sign.

…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
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b3bea83c-04e0-4b6c-8a48-ca8c5ef74595

📥 Commits

Reviewing files that changed from the base of the PR and between e688c0b and ede8f18.


📒 Files selected for processing (1)
  • contrib/openddlparser/code/OpenDDLParser.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



📝 Walkthrough
📝 Walkthrough

Walkthrough

OpenDDL parser helpers and property parsing now check input boundaries before reading characters. When property parsing creates no property, it deletes the parsed identifier. The OpenGEX importer test invokes the importer with two incomplete property values.

Changes

Parser input bounds

Layer / File(s) Summary
Guard reads at end of input
contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h, contrib/openddlparser/code/OpenDDLParser.cpp, test/unit/utOpenGEXImportExport.cpp
Parser helpers and string-property parsing now check input boundaries before reading characters. The parser deletes the identifier when no property is created. The test invokes the importer with two incomplete property values and has no explicit result assertion.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix


Merge Risk: ⚪ Minimal · up to ede8f

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 | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: preventing token helpers from reading past the input buffer.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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
@sonarqubecloud

Copy link
Copy Markdown

@tellypresence tellypresence added Fuzzer Bugs found by a fuzzer OpenDDL Bugs related to OpenDDL format OpenGEX BUgs related to the OpenGEX format labels Oct 13, 2026
@turol

turol commented Oct 13, 2026

Copy link
Copy Markdown
Member

Openddl is a separate component. Please send your PR upstream to https://github.com/kimkulling/openddl-parser

@turol turol closed this Oct 13, 2026
@Mohil-Ahuja

Copy link
Copy Markdown
Contributor Author

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 isNotEndOfToken, isFloat, isHexLiteral, isReference, the comment helpers and the string-literal branch in parseProperty, along with more parser changes. So I won't open a duplicate there.

Once #98 is merged and contrib/openddlparser is synced, this PR isn't needed and I'll close it. The OpenGEX test here (importPropertyAtEndOfFileNoCrash) could come with the sync if that's useful. Or I can close this now if you'd rather track it only upstream.

@turol

turol commented Oct 13, 2026

Copy link
Copy Markdown
Member

Make a separate PR of the unit test.

@Mohil-Ahuja

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fuzzer Bugs found by a fuzzer OpenDDL Bugs related to OpenDDL format OpenGEX BUgs related to the OpenGEX format

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants