Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add fuzzing, fix panics #31

Merged
merged 6 commits into from
Aug 2, 2022
Merged

Conversation

HeroicKatora
Copy link
Contributor

Based on #23 but also fixes all panics found via such fuzzing. These are essentially already found in issues.

Closes: #22
Closes one other panic in malformed templates: An input ending in a literal with escape \ would reenter the parsing loop another time with empty input and escaped set, but conume_text assumes at least one byte to be present when escaped is set.

@bheisler
Copy link
Owner

Hey, thanks for the pull request.

I'd never really considered fuzzing this code since the templates are typically compiled into the executable (ie. hopefully not attacker-controlled) and therefore not security-sensitive. These are problems that a regular user might run into though, so thanks for doing the legwork for me.

In addition to the one request for a comment, could you add a couple of regular unit tests to demonstrate the erroneous cases the fuzzer found? Thanks!

When closing a tag (block, or other), the search function did not
consider that the start and end tags can overlap in their symbols. It
also assumes a minimum length for the matching sequence based on a
complete start and complete end tag. These combined would cause range
errors by accessing the incorrect content such as:

	{#}

	// src/compiler.rs:58
	comment = tag[2..1].trim()

This is fixed by skipping the start tag for the purpose of searching for
the end tag, assuming the start tag has equal with.
@HeroicKatora
Copy link
Contributor Author

That should have addressed everything. Can you give it another review?

@bheisler bheisler merged commit 141836d into bheisler:master Aug 2, 2022
@bheisler
Copy link
Owner

bheisler commented Aug 2, 2022

Thanks for the pull request!

@HeroicKatora HeroicKatora deleted the add-fuzzing branch August 2, 2022 23:56
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic with malformed template {#}
3 participants