(&self, fuzzer_binary: &Path, corpus: &Path)
| 735 | } |
| 736 | |
| 737 | pub fn spawn_libfuzzer(&self, fuzzer_binary: &Path, corpus: &Path) -> Result<Child> { |
| 738 | let fuzzer_dir = crate::deopt::utils::get_file_dirname(fuzzer_binary); |
| 739 | if !fuzzer_binary.exists() { |
| 740 | eyre::bail!("fuzzer {fuzzer_binary:?} does not exist!") |
| 741 | } |
| 742 | |
| 743 | // run fuzzer in an another dir to avoid fuzzer write or read garbage files. |
| 744 | let fuzzer_work_dir: PathBuf = [fuzzer_dir.clone(), "work".into()].iter().collect(); |
| 745 | crate::deopt::utils::create_dir_if_nonexist(&fuzzer_work_dir)?; |
| 746 | self.deopt.copy_library_init_file(&fuzzer_work_dir)?; |
| 747 | |
| 748 | if !corpus.exists() { |
| 749 | eyre::bail!("fuzzer corpus {corpus:?} does not exist!") |
| 750 | } |
| 751 | |
| 752 | let log_file: PathBuf = [fuzzer_dir.clone(), "fuzz.log".into()].iter().collect(); |
| 753 | let mut extra_args = Vec::new(); |
| 754 | |
| 755 | let dict = self.deopt.get_library_build_dict_path()?; |
| 756 | if dict.exists() { |
| 757 | let dict_arg = format!("-dict={}", dict.to_string_lossy()); |
| 758 | extra_args.push(OsString::from(dict_arg)); |
| 759 | } |
| 760 | |
| 761 | if let Some(fork) = &self.deopt.config.fuzz_fork { |
| 762 | if *fork { |
| 763 | extra_args.push(OsString::from("-fork=1")); |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | let child = self.spawn( |
| 768 | fuzzer_binary, |
| 769 | extra_args, |
| 770 | vec![], |
| 771 | Some(fuzzer_work_dir), |
| 772 | Some(std::fs::File::create(log_file)?.into()), |
| 773 | false, |
| 774 | ); |
| 775 | Ok(child) |
| 776 | } |
| 777 | |
| 778 | pub fn run_libfuzzer( |
| 779 | &self, |
no test coverage detected