Skip to content

Commit 628032a

Browse files
committed
Update arbitrary
Signed-off-by: koushiro <[email protected]>
1 parent 2542ae4 commit 628032a

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
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: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
extern "C" {
2-
#![allow(improper_ctypes)] // we do not actually cross the FFI bound here
1+
#![allow(improper_ctypes)] // we do not actually cross the FFI bound here
32

3+
extern "C" {
44
fn rust_fuzzer_test_input(input: &[u8]);
55
}
66

7-
#[export_name="LLVMFuzzerTestOneInput"]
7+
#[export_name = "LLVMFuzzerTestOneInput"]
88
pub fn test_input_wrap(data: *const u8, size: usize) -> i32 {
9-
::std::panic::catch_unwind(|| unsafe {
9+
let test_input = ::std::panic::catch_unwind(|| unsafe {
1010
let data_slice = ::std::slice::from_raw_parts(data, size);
1111
rust_fuzzer_test_input(data_slice);
12-
})
13-
.err().map(|_|
12+
});
13+
if test_input.err().is_some() {
1414
// hopefully the custom panic hook will be called before and abort the
1515
// process before the stack frames are unwinded.
16-
::std::process::abort()
17-
);
16+
::std::process::abort();
17+
}
1818
0
1919
}
2020

21-
#[export_name="LLVMFuzzerInitialize"]
21+
#[export_name = "LLVMFuzzerInitialize"]
2222
pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize {
2323
// Registers a panic hook that aborts the process before unwinding.
2424
// It is useful to abort before unwinding so that the fuzzer will then be
@@ -29,7 +29,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
2929
// We will be able to remove this code when
3030
// https://github.com/rust-lang/cargo/issues/5423 is fixed.
3131
::std::panic::set_hook(Box::new(|_| {
32-
::std::process::abort();
32+
::std::process::abort();
3333
}));
3434
0
3535
}
@@ -38,7 +38,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
3838
macro_rules! fuzz_target {
3939
(|$bytes:ident| $body:block) => {
4040
#[no_mangle]
41-
pub extern fn rust_fuzzer_test_input($bytes: &[u8]) {
41+
pub extern "C" fn rust_fuzzer_test_input($bytes: &[u8]) {
4242
$body
4343
}
4444
};
@@ -47,7 +47,7 @@ macro_rules! fuzz_target {
4747
};
4848
(|$data:ident: $dty: ty| $body:block) => {
4949
#[no_mangle]
50-
pub extern fn rust_fuzzer_test_input(bytes: &[u8]) {
50+
pub extern "C" fn rust_fuzzer_test_input(bytes: &[u8]) {
5151
use arbitrary::{Arbitrary, RingBuffer};
5252

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

0 commit comments

Comments
 (0)