diff options
| author | Ted Nyman <tnyman@openai.com> | 2026-07-20 15:31:20 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-07-21 10:33:14 -0700 |
| commit | dd674df3267112248b0012ce614168055a416920 (patch) | |
| tree | 7a6068af5ace33d82ad0684e26d67551a8e38f11 /gitweb/gitweb.css | |
| parent | e9019fcafe0040228b8631c30f97ae1adb61bcdc (diff) | |
pathspec: use match for sparse-index expansion checks
The pathspec parser computes `len` and `nowildcard_len` from
`item.match`, which includes any prefix added when a command is run
from a subdirectory. `item.original` can still contain the shorter,
unprefixed argument.
Using `item.original + item.nowildcard_len` in
`pathspec_needs_expanded_index()` can therefore read past the end of
the allocation. AddressSanitizer reports a heap-buffer-overflow for
prefixed wildcard pathspecs passed to `git rm` and `git reset` with a
sparse index.
The mismatch dates back to 4d1cfc1351 ("reset: make --mixed
sparse-aware", 2021-11-29), which introduced the helper using
`item.original`. b29ad38322 ("pathspec.h: move
pathspec_needs_expanded_index() from reset.c to here", 2022-08-07)
later moved it to `pathspec.c` and preserved the affected comparisons.
Use `item.match` consistently when checking whether a pathspec can
match a sparse-directory entry. Add coverage for prefixed wildcard
pathspecs so both commands keep the index sparse.
Signed-off-by: Ted Nyman <tnyman@openai.com>
Reviewed-by: Taylor Blau <ttaylorr@openai.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gitweb/gitweb.css')
0 files changed, 0 insertions, 0 deletions
