mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
uucore: use Duration::saturating_mul in parse_time
Use `Duration::saturating_mul()` to avoid a panic due to overflow in `uucore::parse_time::from_str()`. This change prevents panic on very large arguments to timeout and sleep.
This commit is contained in:
parent
8c36558871
commit
388cb6c83a
3 changed files with 99 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
// spell-checker:ignore dont
|
||||
use crate::common::util::*;
|
||||
|
||||
// FIXME: this depends on the system having true and false in PATH
|
||||
|
@ -64,3 +65,19 @@ fn test_preserve_status() {
|
|||
.no_stderr()
|
||||
.no_stdout();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dont_overflow() {
|
||||
new_ucmd!()
|
||||
.args(&["9223372036854775808d", "sleep", "0"])
|
||||
.succeeds()
|
||||
.code_is(0)
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
new_ucmd!()
|
||||
.args(&["-k", "9223372036854775808d", "10", "sleep", "0"])
|
||||
.succeeds()
|
||||
.code_is(0)
|
||||
.no_stderr()
|
||||
.no_stdout();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue