File tree Expand file tree Collapse file tree 1 file changed +25
-11
lines changed
Expand file tree Collapse file tree 1 file changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -7,20 +7,34 @@ use uufuzz::generate_and_run_uumain;
77
88fuzz_target ! ( |data: & [ u8 ] | {
99 let delim: u8 = 0 ; // Null byte
10- let args : Vec <OsString > = data
10+ let fuzz_args : Vec <OsString > = data
1111 . split( |b| * b == delim)
1212 . filter_map( |e| std:: str :: from_utf8( e) . ok( ) )
1313 . map( OsString :: from)
1414 . collect( ) ;
15-
16- // Ensure we have at least a program name
17- if args. is_empty( ) {
18- return ;
15+
16+ // Skip test cases that would cause the program to read from stdin
17+ // These would hang the fuzzer waiting for input
18+ for i in 0 ..fuzz_args. len( ) {
19+ if let Some ( arg) = fuzz_args. get( i) {
20+ let arg_str = arg. to_string_lossy( ) ;
21+ // Skip if -f- or --file=- (reads dates from stdin)
22+ if ( arg_str == "-f"
23+ && fuzz_args
24+ . get( i + 1 )
25+ . map( |a| a. to_string_lossy( ) == "-" )
26+ . unwrap_or( false ) )
27+ || arg_str == "-f-"
28+ || arg_str == "--file=-"
29+ {
30+ return ;
31+ }
32+ }
1933 }
20-
21- let date_main = |args : std :: vec :: IntoIter < OsString >| -> i32 {
22- uumain ( args )
23- } ;
24-
25- let _ = generate_and_run_uumain( & args, date_main , None ) ;
34+
35+ // Add program name as first argument (required for proper argument parsing)
36+ let mut args = vec! [ OsString :: from ( "date" ) ] ;
37+ args . extend ( fuzz_args ) ;
38+
39+ let _ = generate_and_run_uumain( & args, uumain , None ) ;
2640} ) ;
You can’t perform that action at this time.
0 commit comments