Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for defining custom mutators #79

Merged
merged 8 commits into from
May 13, 2021

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented May 13, 2021

See the doc comments for the fuzz_mutator! macro for example usage and user-level information.

There is some slightly funky stuff going on with data, size, and max_size that doesn't feel 100% Rust-y / is a little subtle to support size-aware mutations. data is basically a vec's heap allocation, size is basically vec.len(), and max(size, max_size) is basically vec.capacity(). Not sure that this API can really be improved upon while remaining a thin wrapper over what libfuzzer gives us (i.e. doesn't introduce a ~fork of std::vec::Vec) but I'm open to ideas!

Supersedes #62.

@fitzgen fitzgen requested a review from Manishearth May 13, 2021 01:09
Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Member

@frewsxcv frewsxcv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fitzgen added 2 commits May 13, 2021 09:44
This allows users to force libfuzzer to only perform shrinking mutations.
@fitzgen
Copy link
Member Author

fitzgen commented May 13, 2021

Thanks for review @Manishearth @frewsxcv!

I've pushed a tiny commit that adds a max_size parameter to the libfuzzer_sys::fuzzer_mutate function, so that users can force libfuzzer to only make shrinking mutations on the data they ask it to mutate (the old signature only allowed users to force equal-or-smaller mutations or allow growth as well).

I'll merge and cut a release as soon as CI is green!

@fitzgen fitzgen merged commit f6f3f14 into rust-fuzz:master May 13, 2021
@fitzgen fitzgen deleted the custom-mutators branch May 13, 2021 16:50
@fitzgen
Copy link
Member Author

fitzgen commented May 13, 2021

Published!

@fitzgen fitzgen mentioned this pull request May 13, 2021
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.

3 participants