Skip to content

Commit

Permalink
Eliminate reliance on fs_extra; copy AFL++ directory with shell
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jul 17, 2024
1 parent ead58d0 commit e002b00
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions cargo-afl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ edition = "2021"
[build-dependencies]
anyhow = { version = "1.0", features = ["backtrace"] }
clap = { version = "4.5", features = ["cargo", "derive"] }
fs_extra = "1.3"
home = "0.5"
rustc_version = "0.4"
tempfile = "3.10"
Expand All @@ -25,7 +24,6 @@ xdg = "2.5"
[dependencies]
anyhow = { version = "1.0", features = ["backtrace"] }
clap = { version = "4.5", features = ["cargo", "derive", "string"] }
fs_extra = "1.3"
home = "0.5"
rustc_version = "0.4"
tempfile = "3.10"
Expand Down
29 changes: 17 additions & 12 deletions cargo-afl/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,28 @@ pub fn config(args: &Args) -> Result<()> {
return Err(anyhow!("could not run 'git'"));
}
} else {
let _: u64 = fs_extra::dir::copy(
afl_src_dir,
tempdir.path(),
&fs_extra::dir::CopyOptions {
content_only: true,
..Default::default()
},
)?;
let success = Command::new("cp")
.args([
"-P", // preserve symlinks
"-R", // copy directories recursively
afl_src_dir_str,
&*tempdir.path().to_string_lossy(),
])
.status()
.as_ref()
.map_or(false, ExitStatus::success);
if !success {
return Err(anyhow!("could not copy directory {afl_src_dir:?}"));
}
}

let work_dir = tempdir.path();
let work_dir = tempdir.path().join(AFL_SRC_PATH);

build_afl(args, work_dir)?;
build_afl_llvm_runtime(args, work_dir)?;
build_afl(args, &work_dir)?;
build_afl_llvm_runtime(args, &work_dir)?;

if args.plugins {
copy_afl_llvm_plugins(args, work_dir)?;
copy_afl_llvm_plugins(args, &work_dir)?;
}

let afl_dir = common::afl_dir()?;
Expand Down

0 comments on commit e002b00

Please sign in to comment.