Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seq: mismatch with GNU with long number #6235

Closed
sylvestre opened this issue Apr 14, 2024 · 5 comments · Fixed by #6858
Closed

seq: mismatch with GNU with long number #6235

sylvestre opened this issue Apr 14, 2024 · 5 comments · Fixed by #6858
Labels

Comments

@sylvestre
Copy link
Contributor

sylvestre commented Apr 14, 2024

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 sylvestre changed the title seq: mismatch with GNU with long number seq: mismatch with GNU with long number Apr 14, 2024
@ahmadabd
Copy link
Contributor

ahmadabd commented May 7, 2024

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

@dcampbell24
Copy link
Contributor

How long does it take to run with what cpu?

@sylvestre
Copy link
Contributor Author

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

@steinwand6
Copy link
Contributor

I would like to contribute. Would it be alright if I submit a pull request?

@sylvestre
Copy link
Contributor Author

of course :)

@cakebaker cakebaker linked a pull request Nov 16, 2024 that will close this issue
cakebaker pushed a commit that referenced this issue Nov 20, 2024
* seq: remove ignore flag from test_invalid_float_point_fail_properly(#6235)

* seq: prevent overflow in parse_exponent_no_decimal

* seq: add tests for invalid floating point arguments

* seq: add overflow checks when parsing decimal with exponent

* seq: add overflow checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants