Skip to content

seq: add overflow checks when parsing exponents #6858

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

Merged
merged 10 commits into from
Nov 20, 2024

Conversation

steinwand6
Copy link
Contributor

This pull request addresses issue #6235.

  • Replaced simple '+' with checked_add in parse_exponent_no_decimal and parse_decimal_and_exponent to prevent potential overflow.
  • Enabled the previously ignored test for invalid floating-point inputs.
  • Added a new test to cover cases with decimals and exponents.

@cakebaker cakebaker linked an issue Nov 16, 2024 that may be closed by this pull request
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)

@sylvestre sylvestre force-pushed the seq-with-long-number branch from d11ad7b to a373fa9 Compare November 16, 2024 18:49
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)

@sylvestre
Copy link
Contributor

failed on Windows with:

Diff < left / right > :
<thread 'main' panicked at 'attempt to add with overflow', src\uu\seq\src\numberparse.rs:212:21
<note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
>seq: invalid floating point argument: '-1.1e9223372036854775807'
>Try 'D:\a\coreutils\coreutils\target\i686-pc-windows-msvc\debug\coreutils.exe seq --help' for more information.
 

', tests\by-util\test_seq.rs:790:10
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src\panicking.rs:578
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\core\src\panicking.rs:67
   2: tests::common::util::CmdResult::stderr_is<alloc::string::String>
             at .\tests\common\util.rs:586
   3: tests::common::util::CmdResult::stderr_only<alloc::string::String>
             at .\tests\common\util.rs:642
   4: tests::common::util::CmdResult::usage_error<ref$<str$> >
             at .\tests\common\util.rs:671
   5: tests::test_seq::test_invalid_float_point_fail_properly
             at .\tests\by-util\test_seq.rs:786
   6: tests::test_seq::test_invalid_float_point_fail_properly::closure$0
             at .\tests\by-util\test_seq.rs:780
   7: core::ops::function::FnOnce::call_once<tests::test_seq::test_invalid_float_point_fail_properly::closure_env$0,tuple$<> >
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250
   8: core::ops::function::FnOnce::call_once
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


@steinwand6
Copy link
Contributor Author

Added checks to handle overflows that occur in 32-bit environments. Thank you for pointing out the CI errors.

@cakebaker cakebaker merged commit c986fb7 into uutils:main Nov 20, 2024
62 checks passed
@cakebaker
Copy link
Contributor

Thanks for your PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

seq: mismatch with GNU with long number
3 participants