From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.178 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== 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== 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 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 ; Tue, 1 Dec 2026 18:49:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98365606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-89d6bd67045so5689095b3a.0 for ; Tue, 01 Dec 2026 10:49:56 -0800 (PST) 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) 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) Message-Id: From: "Alessio Attilio via GitGitGadget" Date: Tue, 01 Dec 2026 18:49:54 +0000 Subject: [PATCH] tree-walk: preserve large entry path lengths Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 To: git@vger.kernel.org Cc: Alessio Attilio , Alessio Attilio From: Alessio Attilio 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 --- 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