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

Error mapping in fuzz #163

Open
ionut-arm opened this issue Jan 20, 2020 · 1 comment
Open

Error mapping in fuzz #163

ionut-arm opened this issue Jan 20, 2020 · 1 comment

Comments

@ionut-arm
Copy link

ionut-arm commented Jan 20, 2020

Hello!

I'm trying to setup fuzzing using the fuzz!(|param: Type| { ... }); template (where Type implements Arbitrary), however I keep getting an error from within the macro.

The failure points to the following snippet:

RingBuffer::new($buf, $buf.len())
           .and_then(|mut b| Arbitrary::arbitrary(&mut b).map_err(|_| ""))

Because the closure inside the and_then is supposed to return the same type as RingBuffer::new, the map_err makes my compiler grumpy since it returns &str instead of BufferError.

expected enum arbitrary::BufferError, found &str
help: try using a variant of the expected enum: Ok(Arbitrary :: arbitrary (& mut b) . map_err (| _ | ""))

My use case is pretty simple:

fuzz!(|key_name: String| { 
        let mut test_client = TestClient::new();
        if let Err(ResponseStatus::ConnectionError) = test_client.create_rsa_sign_key(key_name.clone()) {
            panic!("Died for input: {}", key_name);
        }
});

Not sure if this is because of me misunderstanding how the afl crate works or if this is a legit bug.

PS: I'm importing and using arbitrary: "0.2.0"

@adu-web3
Copy link

same problem

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

No branches or pull requests

2 participants