Repository navigation
mingw: use the full buffer when reading reparse points - #6507
VirgilMing wants to merge 1 commit into
Conversation
b1e9fbf to
bdaf6da
Compare
bdaf6da to
b2a0d3a
Compare
|
Rebased this single-commit fix onto current The old run had four cancelled macOS jobs using the unavailable The PR still contains only the original two-file fix and regression tests (43 insertions, 1 deletion). The stable patch ID is unchanged; no workflow changes or test removals were added. Local The new CI, check-style, and check-whitespace workflows were triggered by this update but are awaiting maintainer approval. Could a maintainer please approve the runs so the refreshed branch can be tested? CI run: https://github.com/git-for-windows/git/actions/runs/46155273486 |
dscho
left a comment
There was a problem hiding this comment.
Looks good. I will probably not get to merging this before v2.98.0-rc1, but with this one change, I think this PR is good to go!
| test_cmp expect actual && | ||
| git diff --exit-code -- long-link >actual 2>err && | ||
| test_must_be_empty actual && | ||
| test_must_be_empty err |
There was a problem hiding this comment.
Maybe assert the index size? The existing tests detect lstat() failure but can mask an incorrect nonzero size:
diff --git a/t/t2031-checkout-long-paths.sh b/t/t2031-checkout-long-paths.sh
--- a/t/t2031-checkout-long-paths.sh
+++ b/t/t2031-checkout-long-paths.sh
@@ -145,7 +145,10 @@ do
test_cmp expect actual &&
git diff --exit-code -- long-link >actual 2>err &&
test_must_be_empty actual &&
- test_must_be_empty err
+ test_must_be_empty err &&
+ git add -- long-link &&
+ git ls-files --debug -- long-link >actual &&
+ test_grep "^ size: $bytes[^0-9]" actual
'
done
doneThere was a problem hiding this comment.
@dscho Added the index-size assertions in 69f6503 exactly as suggested. Could you please take another look?
Local syntax/format checks and all six Linux target/index-size checks pass. The updated Windows cases are awaiting CI approval.
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(). Also assert the indexed symlink size after git add, since a clean diff can mask an incorrect nonzero size returned by mingw_lstat(). Fixes: git-for-windows#6498 Co-authored-by: GPT-6 Signed-off-by: vgm <virgilming@gmail.com>
b2a0d3a to
69f6503
Compare
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.git add.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 on the original test version, before the index-size assertions added in response to review:
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.After the review update, shell syntax, whitespace, ASCII and line-width checks pass. The six target/index-size checks also pass with native Linux symlinks. The updated Windows regression cases have not been rerun locally and still need CI validation.