write the raw bytes to the "intput_file";
(&mut self, data: &str, size: &str)
| 177 | |
| 178 | // write the raw bytes to the "intput_file"; |
| 179 | fn handle_file_constraint(&mut self, data: &str, size: &str) -> Result<()> { |
| 180 | let re = Regex::new(r"^input_file(\.\w+)?$")?; |
| 181 | let visitor = self.get_new_visitor()?; |
| 182 | if let Some(file_name) = visitor.match_string_pattern(re) { |
| 183 | let ins_loc = |
| 184 | if let Some(loc) = crate::ast::loc::get_fuzzer_shim_after_loc(&self.src_file)? { |
| 185 | loc |
| 186 | } else { |
| 187 | visitor.get_function_body_begin_loc()? |
| 188 | }; |
| 189 | let init_stmt = format!("\n\tFILE *input_file_ptr = fopen(\"{file_name}\", \"wb\");\n\tif (input_file_ptr == NULL) {{return 0;}}\n\tfwrite({data}, sizeof(uint8_t), {size}, input_file_ptr);\n\tfclose(input_file_ptr);\n"); |
| 190 | self.seek_and_rewrite(ins_loc, 0, &init_stmt)?; |
| 191 | } |
| 192 | Ok(()) |
| 193 | } |
| 194 | |
| 195 | /// change the 'main' function to fuzzable and receive fuzzer input |
| 196 | fn change_fd_to_fuzzer( |
no test coverage detected