πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3367

[PATCH v3 4/5] cat-file: use size_t for the length passed to batch_write()

#3367
From: Elia Pinto
Date: Thu, 19 Nov 2026 06:21
32 lines
11902 bytes
batch_write() takes the length of the data as an "int", but its callers
pass the size of whole objects, a size_t. On all platforms, an object
between 2GiB and 4GiB gets a negative length, which fwrite() and
write_or_die() see as an enormous size_t: "git cat-file --batch" writes
memory past the end of the object to stdout until it dies with "write
error: Bad address". Larger objects are truncated instead. Blobs are
affected only with --filters or --textconv, as they are otherwise
streamed.

Both callees take a size_t, so just change the parameter type.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/cat-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 8870a210ec..c846fe3116 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -425,7 +425,7 @@ static void expand_format(struct strbuf *sb, const char *start,
 	}
 }
 
-static void batch_write(struct batch_options *opt, const void *data, int len)
+static void batch_write(struct batch_options *opt, const void *data, size_t len)
 {
 	if (opt->buffer_output) {
 		if (fwrite(data, 1, len, stdout) != len)
-- 
2.53.0
Technical Details
Message-ID: <99bf45c606c9b89fe93118f525d3fcbbf25fcb38.1795069177.git.gitter.spiros@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.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-75783-linux-kernel-git=dewy.ru
References: <cover.1794914210.git.gitter.spiros@gmail.com> <cover.1795069177.git.gitter.spiros@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.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-75783-linux-kernel-git=dewy.ru
From: gitter.spiros@gmail.com (Elia Pinto)
Newsgroups: linux.kernel.git
Subject: [PATCH v3 4/5] cat-file: use size_t for the length passed to batch_write()
Date: Thu, 19 Nov 2026 07:21:49 +0100
Organization: Usenet Network
Message-ID: <99bf45c606c9b89fe93118f525d3fcbbf25fcb38.1795069177.git.gitter.spiros@gmail.com>
References: <cover.1794914210.git.gitter.spiros@gmail.com> <cover.1795069177.git.gitter.spiros@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2805830"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:74u5b+DwPawe8OtmRkCmkWKK7pg= sha256:zPxtbPC7DokiwPwG5qp3UCx9+8US7rS+O0FzDqNPBNg=
	sha1:t/hMZrt/ELfonoqKreE1IgS0buI= sha256:9hMLtQhd0mQbRgpQG7ykI1wzepLFnxGbtPho4ReG0js=
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 527BE115514; Thu, 19 Nov 2026 09:22:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[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 ung6pq0lf9gX;
	Thu, 19 Nov 2026 09:22:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-75783-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 86B74115515; Thu, 19 Nov 2026 09:22:32 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 938C3203078; Thu, 19 Nov 2026 06:22:26 +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=1795069333;
	b=qbniRXkFcrvB8DTEPtZ1a4ecJk2Vwf6cQTH0k1cmh5dcdrp1aR6alyrF0oAroGGdcNWF
	 5jmtBNMFTFjOK430PTEfocmXVTChLqua5nKVd4n0GEsQESysN0wdM8K8jDgPTkNywaL3O
	 USwPB4gV2nBbuT24GxT87QfvDJpSe5eefbSs4vJM9DHDUGOJAQTmF8tsGVmB0KsNaiZR8
	 mcAxmrgQKTmN4uNeFHHm0LSwV+So3x1fYn1+QxxrFgWoSYxXNdsqzKoIIhWejqRPXAbeM
	 7SOocBipF3/z4s+bqPYOomPwqt3/L1qGvUXkBj8sS5ieumbWOrCmll6A2951QnGwpCQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795069333;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Mqp/gnrHfR1movneQoeJlH8Co1+N3aonEVQQEmHA9Jo=;
	b=fx1dc2w36MpvwXNX7Kd/yW6f0zLlx4xqUQdCrvLUIqIGYrJLmWqyMiT6vx7F3JRZKkwK
	 n+99tQqYTJpLXt74nL9Yx7VdK+DTrjIZgaXrkUdcbnv6Xr3vEJhK43X1Wyd97Neg327XF
	 PsFN6CZXvJ1SC0IfRr/+9HlToOVgBBrKxWOrJJS7SYYid2QnT/Q/cxVm7u8xRmQXzHnEJ
	 1LsaDENFYFXYZ5S34tp8+VbUc7I+DSizCS3eq6Qf/5qOqx8SGSU4L1fMawqoDmAjGSjN5
	 OfqPfrVA0gnoEZ3tRq4mUwf8Z+YVS2jbW4h3QQRoK5QpVpe/HooG7Tb0kP4tJXCVAxQ==
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=gxLAwbyU;
	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 25C8F60A2629;
	Thu, 19 Nov 2026 06:22:13 +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=gxLAwbyU
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.45
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795069332;
	b=aE3OP3YT85wCG/4UF012VcC7wHiiRyrilsfts35jm+myCujSym96mpW/c+YT4BJPmJ/D
	 dKtiTR6FkUGM8gTsLHDskz8TRjzNL5EuZGj55vqsRBTYpNBaD8/8MTaFCbiakZjG6cUa9
	 PIQpRfYfQ843IVJpQeLWQDlQXzbU2QXyVDVk9ZtIlHk0w0/luYy+K5bBZc+r3WRBk7u3U
	 iV0wNTFEDd9cIKm718v4lta0d8qfM6HCrREbZEBUZGPJV4p1xqXtJj4b16jET7agoAKEG
	 xLHZ4PZ9WiaW4G8YIKNvm7YfkH8G5TA3xTdPhF4ovFBnp3Vl3oWM2GVMdAsBmMuIdWg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795069332;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Mqp/gnrHfR1movneQoeJlH8Co1+N3aonEVQQEmHA9Jo=;
	b=laFpjFuHCk+RiQELnfCbpKu2Dlqnbg3fySVi279XDyDDVEilgrTdTf0KhRKi+Ha4DjFa
	 +C2N3+gyWwmkQI2Jc+tlJSMA0NOAUjK5UmhCx4jqCVpjMXSeRgXtp7gfYIM1BiWKZbZh7
	 UtjR7j45gkx8d6VYlrEw4WxNEi5ZiZ6u5P4hb1WHBXqEHBINLsgSZHogGGPDObB6DcUeO
	 ksT3C0x0jAoxLe5QEjIAhH4nT2vo/tl5WiwDNknSDPNxZjL4k9Q2EPnuWvYLulbRioWPd
	 zuYdxNb50d9KtJFs0SQder9aoeCMeE5thDJiQ5bpLdEz9C+aAwkM9gapEhPYw/inflQ==
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=gxLAwbyU;
	arc=none smtp.remote-ip=209.85.221.45
X-Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45])
	(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 EDDF160A261E
	for <git@vger.kernel.org>; Thu, 19 Nov 2026 06:22:11 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EDDF160A261E
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-wr1-f45.google.com with SMTP id ffacd0b85a97d-490f38e9688so421999f8f.0
        for <git@vger.kernel.org>; Wed, 18 Nov 2026 22:22:11 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795069330; x=1795674130; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=Mqp/gnrHfR1movneQoeJlH8Co1+N3aonEVQQEmHA9Jo=;
        b=gxLAwbyUs3zbL+0+au87aUQ9rf610WZLBQLL1UgySxUhfk/OQeXJ7pAZiynHLupi63
         Y4fO4XLWv/IcQCBVidvDBMN+Y+uJGxk6BU4V3OaFSAyaQ6+APIgXw0SqjmEb5ziGCRyF
         eTA63Cn97D9ST/r61ZA2pQTOwvbUfGK/0BStz8vc32vaQ8Ji+BNYWfgsFFytEVHpyB+4
         D0VyjmJeDNLtvkW+xXPhsSw6nJu+ui0eu/G+JlcXXwTQ4OjHp3El9LBGln8oa9JVcEre
         w472+sNjxb4p6mYpRputAl3/W0WgKSsBimxeCWMdGFU7DiOBv4VgDlaZ1gwSbGJ0k6of
         Suvg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795069330; x=1795674130;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=Mqp/gnrHfR1movneQoeJlH8Co1+N3aonEVQQEmHA9Jo=;
        b=uYGneYlOtv6JW7xsDEAeQy+O/BvYYsgPyNDUpbN9KmR8g+G+R3Yg1n/TOGtB0M8umb
         neUmqfjiPJ88htnBhOcOfgNDdH/Lyu9TeiYQLkkZkP0aUeoc+wsNDHQnVFv1o3H2hHco
         SW5TNFc1YeDYHGTVRYkrfkpqaj7uSfLEvlcCG+UEip5lKYJh1rZDqjWIE0RYBxSAmQvb
         tF1BQFB39TVBL8j56/Kuw/EZNROjSyFPApVSrWKTwJEOtaNdWa1BaZ9wy1QpHpw0q/g7
         B5ZxRMiYU7/2IdvSlr3HhG3d338l5NLHak1Vup8yhljeCn0zCJDoY4xnZi2ePAVuV5hC
         Yz8w==
X-Gm-Message-State: APuU4Z9N2B/bIaf9cEdzMgQZZGuEYUMcVQTX8lpmHl1Z06XEjl3vU+Q4
	Ln7z3HPWFCrCke8oEsBov81A9XjD0vbhavhVM/5FqrzEgiF2z2rvWq+RFHu3Ng==
X-Gm-Gg: AZFdTZc3ntP+q11DC65fW0i6ChBAtgRF614mxhR4l8TX5Jy4CCdic32RDwHnBGI3mTx
	qPCaWUfp/R3Im8qK8tCV41k8TmUFH77YceF/btfOb53jnyurJT1NVlnSVI9lFMUGt3zgO6LHUUh
	TVtccuReNGo+hNUhS7oBY+u1WFUEh2hyew9MglK4tFMB3ZirOJLMEZcTYk7tI+49zq54aDjE+8t
	NZuWvkysPeCIkK8qaTkqB+qX8WSWVSz3B56Xkb5dYs2UpS8UPcPZ0+Hj9gNou5Epi2U8zyu5BE6
	jGy+yCA4uroA7ddeU1Sfm8LA6+GWBGuleBWdKfyarqVxvpQjzt7fgE8GIHdjcBO2Du9c947Epie
	0VrcciPfqws+A/GHKeKizHOHYjdM4M2VS+i5g3Fis1Z7h60czFNjTABdf5xqcuzE97haq5q74k2
	aVsgC/J/m/dmMAg3/mQ7gK5L+TyJBlK2CmXAK5k4yWGBHWtPD+pE6QaXEKVsSJgtTHfuN2/G6ZN
	DTALdc6Csp3mcTGwBtLxq4jHOam4ZbjMQBP1mEZpNkD9nZ1CJypwrPgKOacBD/vgF3IXmx7Ctqx
	1PMEplk8KqODyeJ7Z67/ynruFj1cx/3lEZeby7u//iqlO7HlQO3m1E0/z8ohLcs=
X-Received: by 2002:a05:6000:29c6:b0:4a7:9630:7b36 with SMTP id ffacd0b85a97d-4aa55bfda9amr217191f8f.21.1795069330361;
        Wed, 18 Nov 2026 22:22:10 -0800 (PST)
X-Received: from ubuntu26lts1.example.com ([151.31.213.44])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4a654a8c406sm8508413f8f.14.2026.11.18.22.22.09
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 18 Nov 2026 22:22:09 -0800 (PST)
X-Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Elia Pinto <gitter.spiros@gmail.com>,
	RenΓ© Scharfe <l.s.r@web.de>,
	Junio C Hamano <gitster@pobox.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <cover.1795069177.git.gitter.spiros@gmail.com>
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