File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,13 @@ fn process_file(
189189 _ => {
190190 let f = File :: open ( file_name)
191191 . map_err_context ( || format ! ( "cannot open {} for reading" , file_name. quote( ) ) ) ?;
192+ if f. metadata ( )
193+ . map_err_context ( || format ! ( "cannot get metadata for {}" , file_name. quote( ) ) ) ?
194+ . is_dir ( )
195+ {
196+ return Err ( USimpleError :: new ( 1 , "read error" . to_string ( ) ) ) ;
197+ }
198+
192199 Box :: new ( f) as Box < dyn Read + ' static >
193200 }
194201 } ) ;
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ fn test_invalid_arg() {
99 new_ucmd ! ( ) . arg ( "--definitely-invalid" ) . fails ( ) . code_is ( 1 ) ;
1010}
1111
12+ #[ test]
13+ fn test_invalid_input ( ) {
14+ new_ucmd ! ( ) . arg ( "." ) . fails ( ) . code_is ( 1 ) ;
15+ }
16+
1217#[ test]
1318fn test_fmt ( ) {
1419 new_ucmd ! ( )
You can’t perform that action at this time.
0 commit comments