File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,16 @@ macro_rules! fuzz_target {
143
143
pub extern "C" fn rust_fuzzer_test_input( bytes: & [ u8 ] ) {
144
144
use libfuzzer_sys:: arbitrary:: { Arbitrary , Unstructured } ;
145
145
146
+ // Early exit if we don't have enough bytes for the `Arbitrary`
147
+ // implementation. This helps the fuzzer avoid exploring all the
148
+ // different not-enough-input-bytes paths inside the `Arbitrary`
149
+ // implementation. Additionally, it exits faster, letting the fuzzer
150
+ // get to longer inputs that actually lead to interesting executions
151
+ // quicker.
152
+ if bytes. len( ) < <$dty as Arbitrary >:: size_hint( 0 ) . 0 {
153
+ return ;
154
+ }
155
+
146
156
let mut u = Unstructured :: new( bytes) ;
147
157
let data = <$dty as Arbitrary >:: arbitrary_take_rest( u) ;
148
158
You can’t perform that action at this time.
0 commit comments