Skip to content

Conversation

@jkugelman
Copy link
Contributor

Fuzz testers love to muck with length fields and trigger OOM panics. This is documented in #1459.

This PR fixes the linked issue, though my solution is not the suggested one. Rather than adding a new combinator, I've updated many_m_n and count to clamp their Vec::with_capacity calls to 64KiB. This greatly reduces (though does not eliminate) the risk of OOM panics while still providing most of the benefit of preallocating memory.

Clamping initial capacity to 64KiB does not affect correctness. Nom will still read the full number of elements. The initial capacity is just a performance hint.

@Geal
Copy link
Collaborator

Geal commented Sep 12, 2022

That sounds good, it's an easy way to make it more reliable, thanks!

@Geal Geal merged commit 3645656 into rust-bakery:main Sep 12, 2022
@jkugelman jkugelman deleted the clamp-capacity branch September 12, 2022 19:58
@jkugelman
Copy link
Contributor Author

Follow-up fix: #1549

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