Repository navigation
cli: fix a heap read with --output-dir-mirror=/ - #5051
Merged
Merged
Conversation
hyc-alt
force-pushed
the
fix/cli-mirror-path-and-fnt-safety
branch
from
December 2, 2026 08:25
3827e3d to
acc61d5
Compare
For a top-level file, convertPathnameToDirName() turned "/file" into "", and FIO_createFilename_fromOutDir() then read outDirName[-1]. Keep the root separator, as dirname() does: "/file" and "/" give "/".
Cyan4973
force-pushed
the
fix/cli-mirror-path-and-fnt-safety
branch
from
December 4, 2026 01:03
acc61d5 to
8032592
Compare
Contributor
|
Thanks for the report and the fix.
The commit keeps you as its author. |
Contributor
Author
|
Thanks for rebasing and narrowing this down, @Cyan4973! The reduced commit looks very clean. I'll follow up with a separate PR for Windows |
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.
What and why
zstd --output-dir-mirror=/ filereads one byte before a heap buffer (AddressSanitizer, inFIO_createFilename_fromOutDir()).For a top-level file,
convertPathnameToDirName()turned"/file"into"", andFIO_createFilename_fromOutDir()then readoutDirName[-1].convertPathnameToDirName()now keeps the root separator, asdirname()does:"/file"and"/"give"/".Reduced and rebased onto
devby a maintainer: the other changes first proposed here are either already fixed ondev(#5015) or left for a separate PR (see the comment below).Tests & Verification
tests/cli-tests/file-handling/directory-mirror-root.sh: the input is missing, so nothing is written to/.It fails on
devunder AddressSanitizer (as in theclang-asan-ubsan-cli-testsCI job), and passes with this fix.util.cpasses a C90 syntax check with gcc and MinGW-w64, and the MinGW-w64 build passes with-Werror.Checklist
A gain in one configuration is not a general gain: see the Performance section of CONTRIBUTING.md.
Tools used
AddressSanitizer, UndefinedBehaviorSanitizer, MinGW-w64 cross-compiler, and an AI coding assistant (used for static code review, patch drafting, and regression test drafting).