MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / count_parent_prefix

Function count_parent_prefix

hail-fuzz/src/utils.rs:217–246  ·  view source on GitHub ↗

Returns a count of the number of bytes within each stream shared with the parent input.

(
    fuzzer: &Fuzzer,
    input_id: usize,
    extension_only: bool,
)

Source from the content-addressed store, hash-verified

215
216/// Returns a count of the number of bytes within each stream shared with the parent input.
217pub fn count_parent_prefix(
218 fuzzer: &Fuzzer,
219 input_id: usize,
220 extension_only: bool,
221) -> HashMap<u64, usize> {
222 let input = &fuzzer.corpus[input_id];
223
224 if !input.metadata.stage.is_extension() && extension_only {
225 return HashMap::new();
226 }
227 let Some(parent) = input.metadata.parent_id
228 else {
229 return HashMap::new();
230 };
231 let parent_data = &fuzzer.corpus[parent].data;
232
233 let mut extensions = HashMap::new();
234 for (addr, stream) in &input.data.streams {
235 let Some(parent_stream) = parent_data.streams.get(addr)
236 else {
237 continue;
238 };
239
240 let shared_prefix =
241 stream.bytes.iter().zip(&parent_stream.bytes).take_while(|(a, b)| a == b).count();
242 extensions.insert(*addr, shared_prefix);
243 }
244
245 extensions
246}
247
248#[cfg(test)]
249mod tests {

Callers 2

startMethod · 0.85
startMethod · 0.85

Calls 3

is_extensionMethod · 0.80
getMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected