Skip to content

touch: fix char-boundary panic on a multibyte char in a -t timestamp#12619

Open
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:touch-fix-timestamp-char-boundary
Open

touch: fix char-boundary panic on a multibyte char in a -t timestamp#12619
leeewee wants to merge 1 commit into
uutils:mainfrom
leeewee:touch-fix-timestamp-char-boundary

Conversation

@leeewee
Copy link
Copy Markdown
Contributor

@leeewee leeewee commented Jun 5, 2026

Fixes #12618

touch -t '€123456789' (a leading multibyte char in a 10- or 13-char timestamp) aborted with "byte index N is not a char boundary": prepend_century byte-sliced s[..2] to read the YY digits, splitting the multibyte char.

Take the first two chars instead of byte-slicing, so a multibyte/non-digit prefix yields the invalid-date error (exit 1) like GNU instead of crashing. Adds a regression test.

`touch -t '€123456789'` aborted with "byte index N is not a char
boundary". `parse_timestamp` routes timestamps whose char count is 10 or
13 through `prepend_century`, which byte-sliced `s[..2]` to read the YY
digits; a leading multibyte char (e.g. '€') made byte index 2 land
mid-UTF-8 and panic before the `parse::<u32>()` error could fire.

Take the first two chars instead of byte-slicing, so a multibyte/non-digit
prefix yields the invalid-date error (exit 1) like GNU instead of crashing.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/retry (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Congrats! The gnu test tests/dd/no-allocate is now passing!
Congrats! The gnu test tests/seq/seq-epipe is now passing!

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.

touch panics (str char-boundary) on a multibyte char in a -t timestamp

1 participant