(
&self,
binary: &Path,
extra_args: Vec<S>,
extra_envs: Vec<(S, S)>,
current_dir: Option<PathBuf>,
stderr: Option<Stdio>,
enough_timeout: bool,
| 191 | } |
| 192 | |
| 193 | pub fn spawn<S: AsRef<OsStr> + Debug>( |
| 194 | &self, |
| 195 | binary: &Path, |
| 196 | extra_args: Vec<S>, |
| 197 | extra_envs: Vec<(S, S)>, |
| 198 | current_dir: Option<PathBuf>, |
| 199 | stderr: Option<Stdio>, |
| 200 | enough_timeout: bool, |
| 201 | ) -> Child { |
| 202 | let asan_options = self.deopt.get_asan_options(); |
| 203 | let rss_limit = format!( |
| 204 | "-rss_limit_mb={}", |
| 205 | self.deopt.config.rss_limit_mb.unwrap_or_default() |
| 206 | ); |
| 207 | let current_dir = current_dir.unwrap_or(get_file_dirname(binary)); |
| 208 | let stderr = stderr.unwrap_or(Stdio::piped()); |
| 209 | let timeout = if enough_timeout { |
| 210 | crate::config::SANITIZATION_TIMEOUT |
| 211 | } else { |
| 212 | crate::config::EXECUTION_TIMEOUT |
| 213 | }; |
| 214 | |
| 215 | // Prepare fuzzer arguments |
| 216 | let fuzzer_args = vec![ |
| 217 | rss_limit, |
| 218 | format!("-timeout={}", timeout), |
| 219 | "-close_fd_mask=3".to_string(), |
| 220 | ]; |
| 221 | |
| 222 | // Try to wrap with bubblewrap for network isolation |
| 223 | let mut cmd = wrap_command_with_bubblewrap( |
| 224 | binary, |
| 225 | &extra_args, |
| 226 | &extra_envs, |
| 227 | &asan_options, |
| 228 | &fuzzer_args, |
| 229 | ); |
| 230 | |
| 231 | let program = cmd.get_program().to_string_lossy(); |
| 232 | let args: Vec<String> = cmd.get_args().map(|a| a.to_string_lossy().into_owned()).collect(); |
| 233 | |
| 234 | let full_cmd_string = format!("{} {}", program, args.join(" ")); |
| 235 | log::trace!("Raw shell string: {}", full_cmd_string); |
| 236 | |
| 237 | let child = cmd |
| 238 | .current_dir(current_dir) |
| 239 | .stdin(Stdio::null()) |
| 240 | .stdout(Stdio::null()) |
| 241 | .stderr(stderr) |
| 242 | .spawn() |
| 243 | .expect("unable to spawn the fuzzer"); |
| 244 | child |
| 245 | } |
| 246 | |
| 247 | pub fn execute<S: AsRef<OsStr> + Debug>( |
| 248 | &self, |
no test coverage detected