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

Some input in date are panicking the binary #3780

Closed
ioperations opened this issue Aug 5, 2022 · 10 comments · Fixed by chronotope/chrono#759 or #4159
Closed

Some input in date are panicking the binary #3780

ioperations opened this issue Aug 5, 2022 · 10 comments · Fixed by chronotope/chrono#759 or #4159
Labels

Comments

@ioperations
Copy link

ioperations commented Aug 5, 2022

using gnu date command

date --version
    gnu 8.30
date "+%Y-%m-%d %H-%M-%S%:::z"
    2022-08-5 09-53-28+00

while executing coreutils' date command

date --version
    0.0.14
date "+%Y-%m-%d %H-%M-%S%:::z"
$ RUST_BACKTRACE=1 ./target/debug/coreutils date "+%Y-%m-%d %H-%M-%S%:::z"
thread 'main' panicked at 'a Display implementation returned an error unexpectedly: Error', /usr/src/rustc-1.59.0/library/alloc/src/string.rs:2399:14
stack backtrace:
   0: rust_begin_unwind
             at /usr/src/rustc-1.59.0/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /usr/src/rustc-1.59.0/library/core/src/panicking.rs:116:14
   2: core::result::unwrap_failed
             at /usr/src/rustc-1.59.0/library/core/src/result.rs:1690:5
   3: core::result::Result<T,E>::expect
             at /usr/src/rustc-1.59.0/library/core/src/result.rs:975:23
   4: <T as alloc::string::ToString>::to_string
             at /usr/src/rustc-1.59.0/library/alloc/src/string.rs:2398:9
   5: uu_date::uumain::uumain
             at ./src/uu/date/src/date.rs:246:37
   6: uu_date::uumain
             at ./src/uu/date/src/date.rs:145:1
   7: coreutils::main
             at ./src/bin/coreutils.rs:95:31
   8: core::ops::function::FnOnce::call_once
             at /usr/src/rustc-1.59.0/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@uutils uutils deleted a comment from ioperations Aug 5, 2022
@sylvestre
Copy link
Contributor

Thanks, it should be easy to fix

@sylvestre
Copy link
Contributor

sylvestre commented Aug 14, 2022

Other occurrence found by the fuzzer published in issue #3785

 ./target/debug/coreutils date '+~\x0a~%\x0a'
thread 'main' panicked at 'a Display implementation returned an error unexpectedly: Error', /rustc/34a6cae28e7013ff0e640026a8e46f315426829d/library/alloc/src/string.rs:2490:14
# or
./target/debug/coreutils date '++%:2\\\x0f' 

I guess this is the same issue

@sylvestre sylvestre changed the title date command panicked ! Some input in date are panicking the binary Aug 16, 2022
@resistor
Copy link
Contributor

It looks like chrono does not support %::z or %:::z format specifiers. I think the right solution is to upstream it there?

@resistor
Copy link
Contributor

Looks like this was just added to chrono, actually: chronotope/chrono@5f54101

@sylvestre sylvestre moved this to Todo in GNU Compatibility Aug 18, 2022
@qarmin
Copy link

qarmin commented Aug 27, 2022

I have still same problem when running app with this arguments in latest git version of chrono cargo run -- "+␅+%+␄^%)"

@idwer
Copy link

idwer commented Nov 18, 2022

Apparently this behaviour is fixed in main, commit af28337

@tertsdiepraam
Copy link
Member

Excellent! I think we can close this after we made a regression test for it.

@sylvestre
Copy link
Contributor

working on it :)

Repository owner moved this from Todo to Done in GNU Compatibility Nov 27, 2022
@qarmin
Copy link

qarmin commented Nov 27, 2022

What about other panics from issue like cargo run '+~\x0a~%\x0a' or cargo run "+␅+%+␄^%)" ?
New issue should be created?

@sylvestre
Copy link
Contributor

yes please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
6 participants