MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / change_input_data_fuzzable

Method change_input_data_fuzzable

src/program/transform.rs:208–227  ·  view source on GitHub ↗

change the data input read from file to read from fuzzer.

(&mut self)

Source from the content-addressed store, hash-verified

206
207 /// change the data input read from file to read from fuzzer.
208 fn change_input_data_fuzzable(&mut self) -> Result<()> {
209 let visitor = self.get_new_visitor()?;
210 // whether needs to cast the type of bytes.
211 let init_stmt = if let Some(ty_name) = visitor.find_ty_with_arg_name("data") {
212 // whether append a null terminator at the end of bytes.
213 if self.deopt.config.should_terminate_with_null() {
214 format!("FDPConsumeRawBytesWithNullTerm({ty_name}, data, size, fdp)")
215 } else {
216 format!("FDPConsumeRawBytes({ty_name}, data, size, fdp)")
217 }
218 } else if self.deopt.config.should_terminate_with_null() {
219 "FDPConsumeRawBytesWithNullTerm(const uint8_t *, data, size, fdp)".to_string()
220 } else {
221 "FDPConsumeRawBytes(const uint8_t *, data, size, fdp)".to_string()
222 };
223 self.fuzzer_shim.append_fuzzer_stmt(init_stmt);
224 self.write_fuzzer_vars_stmts()?;
225 replace_string_in_file(&self.src_file, "const uint8_t *data; size_t size;", "")?;
226 Ok(())
227 }
228
229 /// make up a variable for this call's string arg.
230 fn makeup_call_string_arg(

Callers 1

transform_to_fuzzerMethod · 0.80

Calls 6

replace_string_in_fileFunction · 0.85
get_new_visitorMethod · 0.80
find_ty_with_arg_nameMethod · 0.80
append_fuzzer_stmtMethod · 0.80

Tested by

no test coverage detected