Repository navigation
mingw: use the full buffer when reading reparse points - #6507
Open
VirgilMing wants to merge 1 commit into
Open
VirgilMing wants to merge 1 commit into
VirgilMing wants to merge 1 commit into
Conversation
read_reparse_point() limits its UTF-16 to UTF-8 conversion to MAX_PATH bytes, although both callers provide a MAX_LONG_PATH-sized buffer. Since the conversion includes the terminating NUL, symlink targets of 260 or more UTF-8 bytes fail with ERANGE. This affects both readlink() and mingw_lstat(), even for short link paths and with core.longpaths enabled. Use MAX_LONG_PATH for the conversion, matching the buffers allocated by the callers. Add Windows regression coverage for ASCII and multibyte targets of 259, 260 and 261 bytes. Check the decoded target as well as the diff output and stderr, since git diff can report the conversion error without failing its exit status. Disable the filesystem cache so the tests also exercise mingw_lstat(). Fixes: git-for-windows#6498 Co-authored-by: GPT-6 Signed-off-by: vgm <virgilming@gmail.com>
This branch has not been deployed
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.
This PR fixes #6498.
Before this PR,
read_reparse_point()passesMAX_PATHto the UTF-16-to-UTF-8 conversion, while both callers already allocateMAX_LONG_PATHbytes.The conversion includes the terminating NUL, so the existing code fails with
ERANGE(Result too large) for targets of 260 or more UTF-8 bytes.The failure affects both
readlink()andmingw_lstat()independently ofcore.longpaths; multibyte targets can reach that byte limit with far fewer than 260 characters.MAX_LONG_PATH, matching the buffers that the callers already allocate.t2031-checkout-long-paths.shscript.mingw_lstat()and setcore.longpaths=falseto demonstrate that the short link pathname does not require that option.readlink()truncation behavior remain unchanged.I built the unmodified
maincode (5cf10d74486d1e59b9ae6cedaedb4e26314e1557) and the patched code on native Windows 11 with MSYS2 UCRT64 GCC 16.2.0.I used
DEVELOPER=1,CFLAGS='-O0 -g'andNO_RUST=1, and disabled optional curl, expat, OpenSSL, gettext, iconv, Perl, Python and Tcl/Tk features for these local validation builds.Those build settings are not changes in this PR.
I performed the following checks:
t2031-checkout-long-paths.shsuite against both binaries. Against the unmodified code, four of this PR's new cases fail withResult too largeat 260/261 bytes. Against the patched code, all 14 tests pass with no skips: the seven pre-existing tests, the new setup test and the six new regression cases.t0060-path-utils.sh,t2007-checkout-symlink.sh,t2102-update-index-symlinks.sh,t4011-diff-symlink.shandt7515-status-symlinks.sh. Together, they execute 219 tests successfully and skip 20 according to their prerequisites. This host's shelllnlacks native symlink support; this PR's new regression cases use Windowsmklink, and all six execute successfully.