diffutils: fix panic on non-UTF-8 argument ending in --width=N#250
Open
SAY-5 wants to merge 1 commit into
Open
diffutils: fix panic on non-UTF-8 argument ending in --width=N#250SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Contributor
Merging this PR will degrade performance by 3.03%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | cmd_cmp_gnu_equal[1000] |
12.2 µs | 13.1 µs | -6.35% |
| ❌ | Simulation | cmd_cmp_release_equal[25000] |
13 µs | 13.7 µs | -5.76% |
| ❌ | Simulation | cmd_cmp_release_equal[100] |
13.2 µs | 13.8 µs | -4.16% |
| ❌ | Simulation | cmd_cmp_release_equal[10000] |
13 µs | 13.5 µs | -3.74% |
| ⚡ | Simulation | cmd_diff_release_equal[1000] |
13.5 µs | 12.9 µs | +5.28% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing SAY-5:fix-width-non-utf8-panic (8fdc882) with main (dc9ca17)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
diffpanicked with exit 101 on a non-UTF-8 argument whose lossy form ends in--width=N, e.g.diff $'\xff--width=5' A B. The--widthregex was missing the leading^anchor that--tabsizealready has, so the lossy (U+FFFD) form matched and the followinginto_string().unwrap()then failed on the real bytes.Anchoring the regex (
^--width=...$, matchingtabsize_re) makes such an argument fall through to the operand path instead of being parsed as a width option, so it no longer panics. As a side effectdiff xyz--width=5is now also treated as a filename rather than silently accepting a width.Added a
widthtest and a#[cfg(unix)]regression test for the non-UTF-8 case.Fixes #247.