From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.148 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796137900; b=YAm3UVNLcdDQVy/ogcrwBradc64luGI4c8vKXZ3nIWHYPcZSXDGWm+GrPBTXCCndAylB Dkx1o4QMaZuL7zLzzf3Fy5ysBMUpcZ5NCrAE9bTeMrtc0xHIrkwVvrxPxQkFJORiRluIH BmoSonfoNQdkAht4pe0zUd4QW5Gx6NKDW1Ws94zNUNi25QMjySrErhmwnECGewW79RNgA LfsQO/l7KTLrU/fS7EU/+XAwf2/DRV5vsmVD+6zEo2CBjHqIJ9ZFial3BL+AP+rRev+iB r4r+qeq9ANP88XJQnIeeAz5Ww614BpaKZulu1jggH5xy/CZCY6qT455xNw8/znpk+wQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796137900; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=0JOo8rGrHBwt201J/HSEnjiXKhaIsXnrDMbfon0Ir44=; b=zR7OxwfDeqrO71jnaPhGGR664sMxewsuPHPF5ecAqmMn6PwcjQD/fEjBB+pK6u1VXJNX P74U2Fbx+cSyIUE/YIZHfeE35CDWVBqRKc9KrmdElkow1OV3F5VFefkJmW1KoiAnqQb7N B2cZCOISSlf9iDwIHjthF45qOxUNzp+jqYBhvwQBFs8VVBpd096OJsdl9rDRDch6PxqY5 jT3J9aivP33ASizZcNDVjaGxuIMOvgpDSqQtc7ukpDB3yF6yntFmc9jif7ClOFV3uhIqh wCfVagYisr8UCR+4EK3ZPB6Bbz8Va7qC7BKnhOm4RY09BX18klGo+WOw4y4+l921JtA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=eJ67CCpB; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=IP36Sudz; arc=none smtp.remote-ip=202.12.124.148 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A3B4606A320 for ; Tue, 1 Dec 2026 15:11:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9A3B4606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=eJ67CCpB; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=IP36Sudz Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id E8DCB1D0059F for ; Tue, 1 Dec 2026 10:11:38 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 01 Dec 2026 10:11:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1796137898; x=1796224298; bh=0JOo8rGrHB wt201J/HSEnjiXKhaIsXnrDMbfon0Ir44=; b=eJ67CCpBZU1c/Q5Z+XmDQlTSlC ph7dXzmC/GuqtivrIZ7VTzco9ucK8vrZooiH+sm/1QVZbZN/JzhtFjSoRXuTy5yv kFpRepy4sn5CeBDWuvtQrEPrvWaHQcThnxhCfUfLiLZTlxqhx5OBJBvtmA8QdVV3 EZycYTB8+0sMgRO5s6PAAx74rhGPc6kZkBw1Z0Xu6xRlsK7ScPeC9QCxNZSGo7XH 9E1uwFhG5HbIKSX36UZllHYiCODr9U4FDRtEh4GK3UeRg0St/4UZvHSoj3PITY7w Lf0IlrDAH7lzNfUV5KeGUx+SaK1fATXjR9Ohw3hl9FbWX6F2RxP4q8w79Y1Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796137898; x=1796224298; bh=0JOo8rGrHBwt201J/HSEnjiXKhaIsXnrDMb fon0Ir44=; b=IP36SudzMFnyyc+rpq5TlG+bbGB64PjcKN2YhmKVE3Rk2gvCP8+ G2QZNMLgATKNs9wU3iOEcdDKFvUOTEl+6PXjG/WFxt/xlPWlD5+GssBHs85OcjMY sFNX01O42b0kw8u8wQW5dXi/qHYGK2vObhS8odV+fgW88kgXS5bEBr3O/kmTcGHK IMPf4+1mqKZUq/Ju7ER3zMzJHJeTom7KrScb69H5KUFSD9t/bdM/D8XTG1dmrRZp qoOpS4vBbdb86oJogYldSiT5xKJCjtFa0hZEOmM5z/PLgYAOTIFAG3xTjlORn50D Gh2yO8Yjvb71XgPBb3kfxo6EUGmMBQdDUwQ== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796137898; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:VfdnA7fQ76OItUAzrodAnnu4eTQtPXmWyQZepRUpV/1PmFV sGw7pyskgZi7mIEy6Okov3PQSN+yqSMWXwgMY+rjRkORyjVOqCY4etLk5sthw6EC caQ3b61rygdEkK2ABUT9pAXomKeRP/z4uRroa6JTGABwr/EEnDwfc3AoKictsVG4 rQvUn6THud+k8joCOfXNcWe1gJ9a1LGWjxBEp+CFSImz8yub9c+g/Eb7LFIXArdY bfyXhUQemcJa7zkZHPX9h0j6mT9Gy7has7LRIUYtK8DujME6rL4g2Q7tJzCvMlL5 gTl5xKAvL6B2lXcw58IEwWiY7vJUBodgPNTY/XA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:A8DKcOYFcX7C3Q4fuJ0QA+6vGV1KVuNGFi7L8IWWMro=:2nTx99fZHQQ7NYS8dijGssdR4yOJ5emu7618RFH3LcA=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEdZN2tMCz0T8gsKfKn1Y7RtyBmJnC5MJG5eOV3g6O5GXkGLLB3JkFkY1SH5+M+Oe 2glxgSPrp/9EkyLlgApmQIrG5fuXQx853NwDveUuKCVk2acU7Pg8qmK8Gouddp1sp0txa+ y+QOJksDaE6CJPFRFEUVdXr6SHL9yQb/pAL0cXLrEArmkKCFF/bj+n+4lmnWqM1XPAfUJh aiD+pbzKirUFy37r8VHsT5b5/1wBxKCbB8P6Rj+zMEm7a0PAQIENMZQCSLyvCMq7adrbre vGBaGoaNLoxR9XEDwGTzjNwV6AD0pTMTozkL9IqPy714znBPnpuoquRFWX90jwFQqwBjVa HaPDVwXF6W7SlCCSQkaIWNgXRPz+x/Qj4LWrT1yFiOxXyH+pdVs4uT55hD79pruPDH+mBk APTPW3PbDq+jTVy+pybjDzeq2Mghw64n+gsHm4Sy8WrBwE2LdSzTOgtxeZSSf35Ehw8b/q TtEz4PZDp46InIPATuVhyTOblAN8MKPLBnggfWLAtL27UkPFDDTsCZoiUrXs8mwai/OqCS eQH1DUAti/pERppQnX1kH8cW1z/XvLvRMB1NCLZZFYyLViax7ymeRYN1b2NLBEW0CPDK9S Ayysoeihm5Ott5beMWkNtCwgH6NNLUywU2zUu77E1lTFkm8HXzfWj+MewR0Q X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Dec 2026 10:11:36 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id b4f7d75c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 1 Dec 2026 15:11:35 +0000 (UTC) Date: Tue, 1 Dec 2026 16:11:33 +0100 From: Patrick Steinhardt To: Kristofer Karlsson via GitGitGadget Cc: git@vger.kernel.org, Elia Pinto , Elijah Newren , Johannes Schindelin , Harald Nordgren , Kristofer Karlsson Subject: Re: [PATCH] tree-walk: reject tree entries whose name length overflows an int Message-ID: References: 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Nov 30, 2026 at 02:42:52PM +0000, Kristofer Karlsson via GitGitGadget wrote: > From: Kristofer Karlsson > > The EXPENSIVE tests 13-15 in t1600 have been failing in CI on all > 64-bit platforms since 53d5cfc3b8 (tree-walk: use size_t for the size > of tree buffers, 2026-10-30) was merged: > > -fatal: index entry path is too long (4294967298 bytes) > +fatal: malformed mode in tree entry > > The tests were added in 89048b48fb (t1600-index: add expensive tests > for over-long tree paths, 2026-10-16). They use a tree with a single > entry whose name is 2^32 - 2 bytes long. decode_tree_entry() stores > that length in the "int" pathlen of struct name_entry, where it wraps > to -2. update_tree_entry() then uses it to find the next entry, ends > up in the middle of the name, and fails to parse it. Things like this in central data structures make me wonder whether we should be explicit with types. That is, do we really want to have a different maximum tree entry length depending on the platform that you're on? I myself don't think that's sensible, so I wonder whether we should convert this to e.g. an `uint32_t` (or an `int32_t` in case we need negative values). But that's of course outside of the scope of this patch series. > diff --git a/tree-walk.c b/tree-walk.c > index aaac1fd48d..f4b4d3fed7 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; > > @@ -36,6 +36,11 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, size_t siz > return -1; > } > len = strlen(path) + 1; Makes sense to change the type of `len`, as we assign the result of `strlen()` to it. > + if (len - 1 > INT_MAX) { > + strbuf_addf(err, _("too long filename in tree entry (%"PRIuMAX" bytes)"), > + (uintmax_t)(len - 1)); > + return -1; > + } So restricting the length makes sense to me. But as mentioned above, do we maybe want to check against `INT32_MAX`? I don't think we support any platforms (or whether those even exist) with where int is 16 bits, but I think it does make a ton of sense to behave the same on all platforms. We can then still adapt `struct name_entry::len` at a later point in time. Ideally, we'd also have documentation around this somewhere to spell out that tree entries may at most be INT32_MAX. Thanks! Patrick