Repository navigation
Description
Summary
patches/0002-mingw-accept-posix-shaped-path-arguments.patch (the
"accept POSIX-shaped path arguments" feature) applies its rewrite to every
argv element from argv[1] on — with no notion of which position the
argument occupies. git commit -m, git tag -m, git notes -m message
payloads are not path arguments, but if the message is a single token shaped
like /x... and the converted Windows path exists on the machine, it gets
silently rewritten. That breaks git's literal-bytes contract for messages
(the same contract issue #3 is about, at the message level).
Severity: medium-high — silent content rewrite, machine-state-dependent
(only fires when the converted path exists).
Minimal repro (current shipped build, argv fed directly, no shell)
$ git commit -q --allow-empty -m /c # stored message: c:/ (should be /c)
$ git commit -q --allow-empty -m /c/Windows # stored message: c:/Windows (should be /c/Windows)
$ git tag -a -m /c v1 # annotation body: c:/ (should be /c)
$ git commit -q --allow-empty -m /zz/nosuch # stored message: /zz/nosuch (OK — converted path absent)
Machine-dependence example observed during the audit: -m /d is preserved on
this machine only because D:\d happens to exist (so the literal lookup
succeeds and the patch keeps the original); on a machine without D:\d, the
same command stores d:/. Message bytes should never depend on what
directories happen to exist on the build/user machine.
Mechanism (patch 0002, wmain argv loop)
for (i = 0; i < argc; i++) {
/* skip argv[0]: never rewrite the program name */
const wchar_t *warg = i ? maybe_convert_posix_path_arg(wargv[i])
: wargv[i];
...
}maybe_convert_posix_path_arg() rewrites when:
- the whole arg matches
^/[A-Za-z](:?/|$)(single leading letter), and - the literal does not exist, but the converted
x:/...form does.
No check of whether the position is a pathspec/path-option value or a message
payload.
Impact scope
commit -m,commit --amend -m,tag -m,notes -m,replace -m—
message payloads rewritten.- Config values, grep patterns, etc. are mostly safe in practice only by
accident of the shape check (multi-word values don't match; e.g.
config test.comment '/c note'survives because the token contains a
space).
Fix direction (for the pre-release pass)
Keep the conversion as an explicit, narrow feature:
- never rewrite the value of message options: skip conversion when the
previous argv element is-mor--message(the--message=<x>/
-m<x>attached forms are single tokens starting with-and can never
match the shape check anyway); -F/--filevalues are file paths and keep benefiting from the
exists-checked conversion (git commit -F /d/msg.txtworks and should
stay working);- everything else keeps the existing double exists-check safety net.
Differential evidence
| command | shipped wrapper stack | shipped real (mingw64) | expected (upstream semantics) |
|---|---|---|---|
commit -m /c |
c:/ |
c:/ |
/c |
commit -m /c/Windows |
c:/Windows |
c:/Windows |
/c/Windows |
tag -a -m /c |
c:/ |
c:/ |
/c |
commit -m /zz/nosuch |
/zz/nosuch |
/zz/nosuch |
/zz/nosuch |
commit -F /d/.../msg.txt |
works | works | works (keep) |
Activity
ci: run the launcher differential suite on the x64 build