coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

`seq`: mismatch with GNU with long number

Open sylvestre opened this issue 1 year ago • 3 comments

Found with fuzzing:

$ cargo run seq 66000e000000000000000000000000000000000000000000000000000009223775807
thread 'main' panicked at src/uu/seq/src/numberparse.rs:114:21:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

with GNU:

$ LANG=C /usr/bin/seq 66000e000000000000000000000000000000000000000000000000000009223
/usr/bin/seq: invalid floating point argument: '66000e000000000000000000000000000000000000000000000000000009223'

sylvestre avatar Apr 14 '24 20:04 sylvestre

I run cargo run seq 66000e000000000000000000000000000000000000000000000000000009223775807 but it does nothing, it just wait.

ahmadabd avatar May 07 '24 04:05 ahmadabd

How long does it take to run with what cpu?

dcampbell24 avatar Jun 09 '24 02:06 dcampbell24

Same issue with -0.e9223372036854775807 - not sure it is the same issue immediate crash

$ RUST_BACKTRACE=1 cargo run -q seq -0.e9223372036854775807
thread 'main' panicked at src/uu/seq/src/numberparse.rs:223:13:
attempt to add with overflow
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:145:5
   3: uu_seq::numberparse::parse_decimal_and_exponent
             at ./src/uu/seq/src/numberparse.rs:223:13
   4: uu_seq::numberparse::<impl core::str::traits::FromStr for uu_seq::number::PreciseNumber>::from_str
             at ./src/uu/seq/src/numberparse.rs:333:44
   5: core::str::<impl str>::parse
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/str/mod.rs:2428:9
   6: uu_seq::uumain::uumain
             at ./src/uu/seq/src/seq.rs:101:15
   7: uu_seq::uumain
             at ./src/uu/seq/src/seq.rs:50:1
   8: coreutils::main
             at ./src/bin/coreutils.rs:110:31
   9: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

found by oss fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68089

sylvestre avatar Jul 08 '24 13:07 sylvestre