Skip to content

tree-walk: reject tree entries with over-long names - #2512

Closed
HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:tree-walk-reject-overlong-path
Closed

HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:tree-walk-reject-overlong-path

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

t1600.13 to t1600.15 have failed in CI on master since ep/tree-walk-size-t was merged:

https://github.com/git/git/actions/runs/46338638011/job/141584820661

I cannot build the 4 GiB tree locally. With the length fields narrowed to 16 bits, a 65534-byte name reproduces the failure.

cc: Elia Pinto gitter.spiros@gmail.com
cc: Johannes Schindelin johannes.schindelin@gmx.de

Three tests in t1600 fail on master when the expensive tests are
enabled, as they are in CI. They were added in 89048b4
(t1600-index: add expensive tests for over-long tree paths,
2026-10-16) and hand checkout, restore and ls-files a tree with an
entry whose name is 4294967294 bytes long. The commands are expected
to refuse the path as too long for the index, and they now die with
"malformed mode in tree entry".

The tree walker keeps the length of an entry's name in an "int", and
this name does not fit. The length comes out as -2, which makes the
walker step forward only 26 bytes in a SHA-1 repository and read the
next entry from the middle of the name.

Before 53d5cfc (tree-walk: use size_t for the size of tree
buffers, 2026-10-30) the size of the tree was truncated to those same
26 bytes. The walk ended there by accident and the tests passed.

Refuse a tree entry whose name is longer than INT_MAX. The three
tests keep checking that the commands refuse such a tree, now with
the message from the tree walker. The limit on the name of a cache
entry is still covered by the "test-tool cache-entry" tests.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
@dscho

dscho commented Nov 30, 2026

Copy link
Copy Markdown
Member

Isn't this a straight-up duplicate of the just-opened gitgitgadget#2342?

@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

@dscho Yes, closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants