Article View: linux.kernel.git
Article #4224[PATCH] tree-walk: preserve large entry path lengths
From: "Alessio Attilio via GitGitGadge...
Date: Tue, 01 Dec 2026 18:49
Date: Tue, 01 Dec 2026 18:49
81 lines
13263 bytes
13263 bytes
From: Alessio Attilio <attilio.alessio@protonmail.com>
The tree buffer uses size_t, but decoded entry lengths were still
stored in unsigned int and int. A large path could therefore be
truncated before tree walkers reached it.
Keep the decoded length as size_t so walkers can reject oversized
index paths correctly.
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
tree-walk: preserve large entry path lengths
Tree entry path lengths are decoded into narrower integer types before
the tree buffer has finished parsing them. Keep the decoded length as
size_t so oversized paths are not truncated before tree walkers can
reject them.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2514%2Fkairosci%2Ftopic%2Ftree-walk-pathlen-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2514/kairosci/topic/tree-walk-pathlen-v1
Pull-Request: https://github.com/git/git/pull/2514
fsck.c | 3 ++-
tree-walk.c | 2 +-
tree-walk.h | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fsck.c b/fsck.c
index 94c8651c7d..9dbf7b6b0d 100644
--- a/fsck.c
+++ b/fsck.c
@@ -659,7 +659,8 @@ static int fsck_tree(const struct object_id *tree_oid,
has_dotdot |= !strcmp(name, "..");
has_dotgit |= is_hfs_dotgit(name) || is_ntfs_dotgit(name);
has_zero_pad |= *(char *)desc.buffer == '0';
- has_large_name |= tree_entry_len(&desc.entry) > max_tree_entry_len;
+ has_large_name |= max_tree_entry_len < 0 ||
+ tree_entry_len(&desc.entry) > (size_t)max_tree_entry_len;
if (is_hfs_dotgitmodules(name) || is_ntfs_dotgitmodules(name)) {
if (!S_ISLNK(mode))
diff --git a/tree-walk.c b/tree-walk.c
index aaac1fd48d..e2b654232e 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -17,7 +17,7 @@
static int decode_tree_entry(struct tree_desc *desc, const char *buf, size_t size, struct strbuf *err)
{
const char *path;
- unsigned int len;
+ size_t len;
uint16_t mode;
const unsigned hashsz = desc->algo->rawsz;
diff --git a/tree-walk.h b/tree-walk.h
index 5ccd4a9361..7c154e7ace 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -16,7 +16,7 @@ struct repository;
struct name_entry {
struct object_id oid;
const char *path;
- int pathlen;
+ size_t pathlen;
unsigned int mode;
};
@@ -61,7 +61,7 @@ static inline const struct object_id *tree_entry_extract(struct tree_desc *desc,
* memory structure of a tree entry to avoid the overhead of using a
* generic strlen().
*/
-static inline int tree_entry_len(const struct name_entry *ne)
+static inline size_t tree_entry_len(const struct name_entry *ne)
{
return ne->pathlen;
}
base-commit: 566b6997dd4710b625c0882cf10a7443bf52d183
--
gitgitgadget
Technical Details
Message-ID:
<pull.2514.git.git.1796150994354.gitgitgadget@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76820-linux-kernel-git=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76820-linux-kernel-git=dewy.ru
From: gitgitgadget@gmail.com ("Alessio Attilio via GitGitGadget")
Newsgroups: linux.kernel.git
Subject: [PATCH] tree-walk: preserve large entry path lengths
Date: Tue, 01 Dec 2026 18:49:54 +0000
Organization: Usenet Network
Message-ID: <pull.2514.git.git.1796150994354.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1792856"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cbPaSsPOt/SsFYiAvGdWOspIFK0= sha256:A7KZOxMfFWe0ovtKuTFKi+YebMDyrHTTHGyNMQMUkn8=
sha1:Yea0B8QbUp0EYDClbzovtlVjgCs= sha256:6B72AZTfcacaGJKoMnalP6X6IW2Qfbn0uGJoCtINouk=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id D4A5A117461; Tue, 1 Dec 2026 21:50:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id sJNTJf7NOY_6;
Tue, 1 Dec 2026 21:50:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76820-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id AB5B311741B; Tue, 1 Dec 2026 21:50:00 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 83C562A783; Tue, 1 Dec 2026 18:49:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796150997;
b=J9OSw0dnCJVVbn4+gTHq7X0d6VT00l+xBTP5W7D3e6SoI7/pO3ImjVCgRfz+/ZYbSf53
+hljvnvXvN/4CVh/r0c2chtcZfdS1SSLYYu/Nwy5jgJ4cRK258mdDOthvduI3BJQxB8Yy
QxkffV0qvkp3qclkLFolZF4DVb6d+RWgcWQjA08CTvcozkQWlaEzMjnkLUWIOs9e0UgK9
lY4Qi4Ns+/aBgvY28fDxV4GgNSsXsicnY0oJJReangZpB1wjH/eOeTkcFFno4cXSPhKyq
djOZ9I4UE7FB4CKQ2tZbuhq/r46yHmBbOTZ4On4rTgBIr5M8tb+lB2RxMq1DZEqxklA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796150997;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Message-Id:From:Date:Subject:Fcc:Content-Type:
Content-Transfer-Encoding:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:To:
Cc;
bh=4uNQ+gKPflfpiYw9Sa6t9py2JgYUs6wqtZKoril7lKk=;
b=lsum8IrCJblSc5zxhtZDC/KuQ9nxvLHrVO9QIYn0fTqihssWytpuA6xmWW0F5lprwVBV
A1BZ8UrxO8pO6ljD6wlG/DoHi1ebuDAM8mfpaEHYMUy+JJGWp61D8A4cUI5sPt8aSVgQN
73nSOsW1qY2QkNWAps9XmFh9IizOv4yIsCLreiDtC4eUhg90LkbGhsarnMv4x7WRV3Y1U
qXvBzq+890DzLifyYGOAm2hmv0l/WXVbs5bV7DfCKjW21wZSM6bDzLXdTnynJ31xIjqz7
WWG8i8tyFlNxz+sk8cLwYGgvl04fKhwJ/vBUaF9lpbAvb1IajH2FK8avDLJ+YibYgBA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=MgEMtZJp;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id D25E5606A32A;
Tue, 1 Dec 2026 18:49:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=MgEMtZJp
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.178
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796150997;
b=zIKgDk9LPQ7QvWoZZ+q9d2KouMvNauB7eQfDnLT0BU6rgniYMnUGONPDk4n865NXkq74
S7EdpVL/SdiPrW+agnTugSeJq9+HFq5igVv+AdEFg/6RojEBV/wzlg3d6+nffWrQERdz/
Vvs5BZy+Bdoud3v6h+W9voLkgBDKzUr57CqtdERfzsvkHLJoa8Uvy1MCxgL8WbxWUx57M
e8ltOVbg2SwKBoqkR/O4u24lbXiCJdK6gTrLKBqJt6NEvkS18uD6fs0lxBV5J8UoK3IM/
SVBkxIjIGuijrAG2NPIwtJoJtq6Xg+13YrnY5wb+L14BhmDI36KZEDk7gFAM0FKtfPQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796150997;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:From:Date:
Subject:Fcc:Content-Type:Content-Transfer-Encoding:MIME-Version:To:
Cc;
bh=4uNQ+gKPflfpiYw9Sa6t9py2JgYUs6wqtZKoril7lKk=;
b=wuupUhpTt429MB/XVy0tNlP5RV/5YrqzkVliEJH85c5kDzZcQBSb24HeNMqPIHcS3k3Z
GSv07lB7PaKsveEYh76NV+Cy4BeVP+sC+do/cVvXtBX87aSf+Kl43tzcaXsYDPxwOp7Db
GJYanaT53mfGW0zHlAUdWPykTPeBn906XDKPx8GKh7WRqD6Mqat0KwkeF3wCgkrL2D3/i
NrZ0zpGYhUmj6Ta1AEU/DcXPeOKv8oVeOreDYAz08YQtLQcNqS2XIECeU4bDpeU5KqfBC
d+U+vfVHuFCWkzVbGn3ZsL2Bfm9P5D/PZOtSxhgARFnv10CI0gY7HNT6K4MIXbBWX4g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=MgEMtZJp;
arc=none smtp.remote-ip=209.85.210.178
X-Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98365606A320
for <git@vger.kernel.org>; Tue, 1 Dec 2026 18:49:56 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98365606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-89d6bd67045so5689095b3a.0
for <git@vger.kernel.org>; Tue, 01 Dec 2026 10:49:56 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796150996; x=1796755796; darn=vger.kernel.org;
h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
:subject:date:from:message-id:from:to:cc:subject:date:message-id
:reply-to:content-type;
bh=4uNQ+gKPflfpiYw9Sa6t9py2JgYUs6wqtZKoril7lKk=;
b=MgEMtZJpnMESrKEbdHyPeWzRkkMpmT+RVoBl4FL7a4jM+Ot7xHAdCHCEae4coC3WOv
4jc4JpX5Dm/tAUUfy8jCAL8+rup6dqtphw6qJcHGBHv3vbtZSUMTBwFo2iYg9JgnqY90
rWYIZCqaSAk+A+TSUrsIVt2JjMIn9JXBnP0uZTixY92YCsNKRM3LVzx+fq1ay2TurrtY
dghIvrVSh8m/9dpWSgGwg9oUz0w3LxqYG2zhy9+ZK/C8uWZqzVaGmcMR9dNZ6BfyXDdZ
GH6mXnzejZfA+jRgMmyxL1zhBR4RAX30e+xZqGsANuHTiQjlX46pUXqSW8C7EqdztpZt
GJQA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796150996; x=1796755796;
h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
:subject:date:from:message-id:x-gm-gg:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=4uNQ+gKPflfpiYw9Sa6t9py2JgYUs6wqtZKoril7lKk=;
b=qyqk2ftXKQzwzoWwXk5eVYTdZ6ktVk3TKt2QDP/VljvSYOvknxvz1zITFBluEqnFYB
aTYnCe9HmUgBrEU7ymT9PB6XsmpOd1zFK0YCXOCvNVJtPXhaH8GBlx9/JULdu5fAmmwx
hE4dq9AV5YowxxWhm/1nIoZavWztsEReK4OzQGeWsIQ8+UBP/s+c4MsOovHKG5IJe38P
iJrIFymxzFOmO9GkQqVheJXs1SFdiQazmhCZFYXMDsYrFp3BfHqeLkKyPgvGrbnPn+RF
/iVeKvCFY9rCXqWzxn94EK7V59WL5gYahUObJWX8Ke0Xc8uYzNywV2ctgwM+7bBGx3Jo
+1gw==
X-Gm-Message-State: APuU4Z/o+8xeV0QUPJBbmJ9z/Ixa+Ka9kViwbJRIukuIUl4uOQkM0w4X
58SNnXJcL18HU/yXyFOvuwaVLSEYcbWBnFQfdmEDJgHKa2WmEO2yMzbVdLyCPw==
X-Gm-Gg: AZFdTZdKtXpxvpfnil9JdAkkVhK9dP2iRTnqwH+vkkFoLvKU16rx5/H3V/KflApe96n
9bMy7qQls8FJRX4YS70p0IBy4E4q23RHHgVo/sPGt2NC8woNZQkPqakYD7D7t1QCb3yHZEJksvH
K0YjspwDpqxhaHqf4no5uhqgxU3Am9IOOCmN0enoRhBqabRK3nvJyEp88vj9LibXaKSnrDTHQ3H
NRA2EhHmVJJvZC6GfmQ1gi3AO7n/SDiF5lB+bEUKrFS+C//bBdgZFFabzxGBZnpyFrp2F/ww4b+
AMaDqV64nIcVCxZ4EdhL2DW4bCKywVgMts3LlyHOkrJPOb8YGC4eFKgtvrHeg+Rgu1KCUkMJTYl
T7/7zqDGAuPwYF3uLB3vtP9B4+RvhoISOWJXd72JiiGFjyZgrF1B1tpnXyCVWPLo0WSGH5U0e9e
4LwqNRpdieTG25ZP/w1/vSL67GQsMaQyrn48PyWbJbIuEVzXKBwKPFc/2i9DjWG76oCV3fp/+H+
snSffqC57y03utON/c7x3ID01NqOp16bDhbeAOUxsQq7xUMmIbAo3wKp0QZMOWDHtd8ftYk+bI8
tGWWOSPV0z0slQeiNDkJ+Stj6HyX4U6gR1uGY1n/sqptGZqBdHcj4joXFGJnTFrF5lXAzTs/Z2t
Df8i8dv1l2w==
X-Received: by 2002:a05:6a00:238b:b0:898:a77f:2833 with SMTP id d2e1a72fcca58-8c87d0249admr26858782b3a.21.1796150995686;
Tue, 01 Dec 2026 10:49:55 -0800 (PST)
X-Received: from [127.0.0.1] (ec2-3-42-157-170.us-west-2.compute.amazonaws.com. [3.42.157.170])
by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8cdfd2d2fc4sm14608796b3a.49.2026.12.01.10.49.54
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 01 Dec 2026 10:49:54 -0800 (PST)
X-Fcc: Sent
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-Cc: Alessio Attilio <attilio.alessio@protonmail.com>,
Alessio Attilio <attilio.alessio@protonmail.com>