dd: exit when bs/ibs/obs/cbs isn't positive

This commit is contained in:
Ibrahim Burak Yorulmaz
2026-04-06 04:08:15 +02:00
committed by Sylvestre Ledru
parent 36265cb9ee
commit 4be5eb9f24
+6 -2
View File
@@ -320,8 +320,12 @@ impl Parser {
}
fn parse_bytes(arg: &str, val: &str) -> Result<usize, ParseError> {
parse_bytes_with_opt_multiplier(val)?
.try_into()
let num = parse_bytes_with_opt_multiplier(val)?;
if num == 0 {
return Err(ParseError::InvalidNumber(val.to_string()));
}
num.try_into()
.map_err(|_| ParseError::BsOutOfRange(arg.to_string()))
}