Skip to content

Commit 8288be3

Browse files
committed
wc: more strict file checking
1 parent 5484350 commit 8288be3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/uu/wc/src/wc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ fn try_get_stdin_size() -> Option<usize> {
5959
return None;
6060
};
6161

62-
if rustix::fs::FileType::from_raw_mode(stat.st_mode) == rustix::fs::FileType::RegularFile {
62+
let file_type = rustix::fs::FileType::from_raw_mode(stat.st_mode);
63+
64+
if file_type == rustix::fs::FileType::RegularFile && stat.st_size > 0 {
6365
return Some(stat.st_size as usize);
6466
}
67+
6568
None
6669
}
6770
#[cfg(not(unix))]

0 commit comments

Comments
 (0)