Skip to content

Commit ff32cf5

Browse files
authored
Merge pull request #45 from koushiro/update
Update arbitrary
2 parents 500b98a + 53dc863 commit ff32cf5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edition = "2018"
1313
members = ["."]
1414

1515
[dependencies]
16-
arbitrary = "0.1"
16+
arbitrary = "0.2"
1717

1818
[build-dependencies]
1919
cc = "1.0"

example_arbitrary/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ members = ["."]
99

1010
[dependencies]
1111
libfuzzer-sys = { path = ".." }
12-
arbitrary = "0.1"
12+
arbitrary = "0.2"

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ extern "C" {
66
fn rust_fuzzer_test_input(input: &[u8]);
77
}
88

9-
#[export_name="LLVMFuzzerTestOneInput"]
9+
#[export_name = "LLVMFuzzerTestOneInput"]
1010
pub fn test_input_wrap(data: *const u8, size: usize) -> i32 {
11-
::std::panic::catch_unwind(|| unsafe {
11+
let test_input = ::std::panic::catch_unwind(|| unsafe {
1212
let data_slice = ::std::slice::from_raw_parts(data, size);
1313
rust_fuzzer_test_input(data_slice);
14-
})
15-
.err().map(|_|
14+
});
15+
if test_input.err().is_some() {
1616
// hopefully the custom panic hook will be called before and abort the
1717
// process before the stack frames are unwinded.
18-
::std::process::abort()
19-
);
18+
::std::process::abort();
19+
}
2020
0
2121
}
2222

23-
#[export_name="LLVMFuzzerInitialize"]
23+
#[export_name = "LLVMFuzzerInitialize"]
2424
pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize {
2525
// Registers a panic hook that aborts the process before unwinding.
2626
// It is useful to abort before unwinding so that the fuzzer will then be
@@ -31,7 +31,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
3131
// We will be able to remove this code when
3232
// https://github.com/rust-lang/cargo/issues/5423 is fixed.
3333
::std::panic::set_hook(Box::new(|_| {
34-
::std::process::abort();
34+
::std::process::abort();
3535
}));
3636
0
3737
}
@@ -40,7 +40,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
4040
macro_rules! fuzz_target {
4141
(|$bytes:ident| $body:block) => {
4242
#[no_mangle]
43-
pub extern fn rust_fuzzer_test_input($bytes: &[u8]) {
43+
pub extern "C" fn rust_fuzzer_test_input($bytes: &[u8]) {
4444
$body
4545
}
4646
};
@@ -49,7 +49,7 @@ macro_rules! fuzz_target {
4949
};
5050
(|$data:ident: $dty: ty| $body:block) => {
5151
#[no_mangle]
52-
pub extern fn rust_fuzzer_test_input(bytes: &[u8]) {
52+
pub extern "C" fn rust_fuzzer_test_input(bytes: &[u8]) {
5353
use libfuzzer_sys::arbitrary::{Arbitrary, RingBuffer};
5454

5555
let mut buf = match RingBuffer::new(bytes, bytes.len()) {

0 commit comments

Comments
 (0)