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

Method synthesis_batch

src/program/libfuzzer.rs:334–368  ·  view source on GitHub ↗
(&mut self, batch_id: &Vec<usize>)

Source from the content-addressed store, hash-verified

332 }
333
334 fn synthesis_batch(&mut self, batch_id: &Vec<usize>) -> Result<String> {
335 let mut stmts = String::new();
336 stmts.push_str(crate::deopt::utils::format_library_header_strings(
337 &self.deopt,
338 ));
339 stmts.push_str("#include <FuzzedDataProvider.h>\n");
340 stmts.push_str("\n\n");
341
342 for id in batch_id {
343 stmts.push_str(&format!(
344 "extern \"C\" int LLVMFuzzerTestOneInput_{id}(const uint8_t* data, size_t size);\n"
345 ));
346 }
347 stmts.push_str("\n\n");
348
349 stmts.push_str(
350 "extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)\n{\n",
351 );
352 stmts.push_str("\tFuzzedDataProvider fdp(data, size);\n");
353 stmts.push_str("\tFDPConsumeIntegral(uint16_t, switch_id, fdp);\n");
354 stmts.push_str("\tconst uint8_t *input = data + sizeof(uint16_t);\n");
355 stmts.push_str("\tsize_t i_size = size - sizeof(uint16_t);\n");
356 stmts.push_str("\tswitch (switch_id) {\n");
357 for (i, id) in batch_id.iter().enumerate() {
358 stmts.push_str(&format!("\t\tcase {i}:\n"));
359 stmts.push_str(&format!(
360 "\t\t\treturn LLVMFuzzerTestOneInput_{id}(input, i_size);\n"
361 ));
362 stmts.push_str("\t\t\tbreak;\n");
363 }
364 stmts.push_str("\t\tdefault:\n");
365 stmts.push_str("\t\t\tbreak;\n");
366 stmts.push_str("\t}\nreturn 0;\n}\n");
367 Ok(stmts)
368 }
369
370 /// If a driver ends with ".cc" and has a seed corpus, it is valid.
371 fn is_valid_driver(&self, driver: &Path) -> bool {

Callers 1

synthesisMethod · 0.80

Calls 1

Tested by

no test coverage detected