-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathafl_v1v2.rs
36 lines (32 loc) · 1.01 KB
/
afl_v1v2.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
#[macro_use]
extern crate afl;
use msmith::{
execution::{
transactional::{TransactionalExecutor, TransactionalInputBuilder, TransactionalResult},
ExecutionManager,
},
MoveSmith,
};
use once_cell::sync::Lazy;
use std::sync::Mutex;
static RUNNER: Lazy<Mutex<ExecutionManager<TransactionalResult, TransactionalExecutor>>> =
Lazy::new(|| {
Mutex::new(ExecutionManager::<TransactionalResult, TransactionalExecutor>::default())
});
fn main() {
fuzz!(|data: &[u8]| {
let smith = MoveSmith::new();
let code = match smith.generate(data) {
Ok(code) => code,
Err(_) => return,
};
let mut input_builder = TransactionalInputBuilder::new();
let input = input_builder.set_code(&code).with_default_run().build();
let bug = RUNNER.lock().unwrap().execute_check_new_bug(&input);
if bug.unwrap() {
panic!("Found bug")
}
});
}