coreutils
coreutils copied to clipboard
Some input in `date` are panicking the binary
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.
Thanks, it should be easy to fix
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
It looks like chrono does not support %::z or %:::z format specifiers. I think the right solution is to upstream it there?
Looks like this was just added to chrono, actually: https://github.com/chronotope/chrono/commit/5f5410163b6655cd0098530f2c6c44bbcc87d102
I have still same problem when running app with this arguments in latest git version of chrono cargo run -- "+␅+%+␄^%)"
Apparently this behaviour is fixed in main, commit https://github.com/uutils/coreutils/commit/af2833761c7d2b8ba9717503683d2b06f848812a
Excellent! I think we can close this after we made a regression test for it.
working on it :)
What about other panics from issue like cargo run '+~\x0a~%\x0a' or cargo run "+␅+%+␄^%)" ?
New issue should be created?
yes please