Skip to content

pr-git-2514/kairosci/topic/tree-walk-pathlen-v2

tagged this 02 Dec 14:25
From: Alessio Attilio <attilio.alessio@protonmail.com>

Tree entry path lengths were stored in unsigned int and int even
though tree buffers are sized with size_t. This truncated paths larger
than those types can represent.

This became visible after 53d5cfc3b8 (tree-walk: use size_t for the
size of tree buffers, 2026-10-30) stopped truncating the tree size:
walkers could reach the full entry, but its path length had already
wrapped. In particular, index path length checks then saw the wrong
length, causing t1600 tests 13-15 to fail with --long.

Keep the decoded length as size_t throughout tree-walk, including its
callers, so the walkers can correctly handle or reject large paths.
Document that names longer than 4096 bytes are not portable, while
leaving rejection of such trees to the configurable fsck check.

Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>

Submitted-As: https://lore.kernel.org/git/pull.2514.v2.git.git.1796221514213.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2514.git.git.1796150994354.gitgitgadget@gmail.com
Assets 2
Loading