Skip to content

Commit 965a719

Browse files
committed
dd: exit when bs/ibs/obs/cbs isn't positive
1 parent 8e05053 commit 965a719

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/uu/dd/src/parseargs.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,12 @@ impl Parser {
320320
}
321321

322322
fn parse_bytes(arg: &str, val: &str) -> Result<usize, ParseError> {
323-
parse_bytes_with_opt_multiplier(val)?
324-
.try_into()
323+
let num = parse_bytes_with_opt_multiplier(val)?;
324+
325+
if num == 0 {
326+
return Err(ParseError::InvalidNumber(num.to_string()));
327+
}
328+
num.try_into()
325329
.map_err(|_| ParseError::BsOutOfRange(arg.to_string()))
326330
}
327331

0 commit comments

Comments
 (0)