Skip to content

Treat reaching the maximum parse depth as EOF#3121

Merged
flavorjones merged 1 commit into
sparklemotion:mainfrom
stevecheckoway:fix-max-tree-depth-error
Feb 4, 2024
Merged

Treat reaching the maximum parse depth as EOF#3121
flavorjones merged 1 commit into
sparklemotion:mainfrom
stevecheckoway:fix-max-tree-depth-error

Conversation

@stevecheckoway

Copy link
Copy Markdown
Contributor

The parser is fragile and hitting the maximum tree depth has exposed several bugs. By treating this condition as if it is an EOF means that we're back in the normal parsing condition.

This does expose a weakness in Gumbo's design: A spec bug that results in skipped steps or failure to reprocess a token (or if we fail to implement the spec in such a way), then the result can be crashes. Not ideal.

Fixes: oss-fuzz-66107

What problem is this PR intended to solve?
oss-fuzz-66107

Have you included adequate test coverage?

Nope! I'm sorry to punt on testing again but I didn't take the time to understand why this bug occurred so I didn't produce a minimal test case. Treating hitting the max depth as EOF just seemed like the best way to fix this whole class of bugs by turning the exceptional (> max depth) parsing case into the normal parsing case.

Does this change affect the behavior of either the C or the Java implementations?

C

The parser is fragile and hitting the maximum tree depth has exposed
several bugs. By treating this condition as if it is an EOF means that
we're back in the normal parsing condition.

This does expose a weakness in Gumbo's design: A spec bug that results
in skipped steps or failure to reprocess a token (or if we fail to
implement the spec in such a way), then the result can be crashes. Not
ideal.

Fixes: oss-fuzz-66107
@flavorjones

Copy link
Copy Markdown
Member

@stevecheckoway Thank you! No sweat on the testing; I feel like things the fuzzer finds aren't always great to add to a functional test suite, anyway.

I manually tested this branch against the fuzzer repro and it looks great! ❤️

@flavorjones flavorjones merged commit 633c7e9 into sparklemotion:main Feb 4, 2024
@flavorjones flavorjones added this to the v1.17.0 milestone Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants