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

Function rand_range

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

Generate a random range between `start..=end` with a maximum size of `max_size`.

(
    rng: &mut R,
    start: usize,
    end: usize,
    max_size: usize,
)

Source from the content-addressed store, hash-verified

95
96/// Generate a random range between `start..=end` with a maximum size of `max_size`.
97pub fn rand_range<R: Rng>(
98 rng: &mut R,
99 start: usize,
100 end: usize,
101 max_size: usize,
102) -> std::ops::Range<usize> {
103 let start: usize = rng.gen_range(start..end);
104 let len: usize = rng.gen_range(1..=(end - start).min(max_size));
105 start..(start + len)
106}
107
108pub fn insert_slice(input: &mut Vec<u8>, x: &[u8], offset: usize) {
109 let position = offset..((offset + x.len()).min(input.len()));

Callers 2

extend_input_byFunction · 0.85
apply_mutationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected