🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2057

[PATCH 0/2] grep, diff: do not silently truncate sizes of 4GiB or more

#2057
From: Elia Pinto
Date: Sun, 01 Nov 2026 08:44
43 lines
12319 bytes
This series continues the search for truncated sizes on platforms where
"long" is 32 bits but size_t is 64 bits (64-bit Windows). This time it
covers grep and diff, where a file of 4GiB or more produced wrong
results without any error.

- 1/2 grep: on the working tree and --no-index, it silently missed
  matches beyond the truncated size. Now it uses size_t and works,
  for blobs too.
- 2/2 diff: on the working tree, textconv, --no-index and combine-diff,
  it produced a diff of a prefix, and a patch that truncates the file
  when applied (as git add -p does). Now it dies with a clear error,
  like the blob side already did.

Of the remaining -Wshorten-64-to-32 warnings in the diff and grep code,
these are the only reachable ones. The others are in xdiff internals
(inputs limited to MAX_XDIFF_SIZE, 1023MiB), in buffer_is_binary()
(which looks at 8000 bytes), or in places where the size can't exceed
4GiB. Widening diff_filespec.size to size_t, so that diff actually works
above 4GiB, is a much bigger change, left for later.

No tests, as they would need 4GiB of input on such a platform. Both
effects were verified by simulating the truncation at 16 bits, and the
commit messages give the details.

It doesn't depend on the other series in flight and merges cleanly with
them. Based on master 50fe5cc63f.

Elia Pinto (2):
  grep: use size_t for the size of buffers to search
  diff: die instead of truncating sizes of 4GiB or more

 combine-diff.c  | 11 +++++++----
 diff-no-index.c |  2 +-
 diff.c          |  8 ++++----
 grep.c          | 16 ++++++++--------
 grep.h          |  4 ++--
 5 files changed, 22 insertions(+), 19 deletions(-)


base-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7
-- 
2.53.0
Technical Details
Message-ID: <cover.1793521916.git.gitter.spiros@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74056-linux-kernel-git=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74056-linux-kernel-git=dewy.ru
From: gitter.spiros@gmail.com (Elia Pinto)
Newsgroups: linux.kernel.git
Subject: [PATCH 0/2] grep, diff: do not silently truncate sizes of 4GiB or more
Date: Sun,  1 Nov 2026 09:44:55 +0100
Organization: Usenet Network
Message-ID: <cover.1793521916.git.gitter.spiros@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2655052"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VGl/CPXzULqpAhL/ilcNubuU/ZM= sha256:Cb76nb3atCWxA0CPiA3Mc8MPpuI0+I9b0DINR0GTZI8=
	sha1:oAjuscZtS+BdKEp4yAfWIOUxjjA= sha256:XT52q7+pv2cr4TJHCfNtJHojBVZSe/emxTmmC73HxHA=
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 31644112308; Sun,  1 Nov 2026 11:45:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.948
X-Spam-Status: No, score=-0.948 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, FORGED_GMAIL_RCVD=1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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 B2AGJVB9QqIU;
	Sun,  1 Nov 2026 11:45:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74056-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 16FA91122D3; Sun,  1 Nov 2026 11:45:08 +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 F031629010; Sun,  1 Nov 2026 08:45:02 +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=1793522702;
	b=fJbk6pHRXTiDpdF2QL6HlVkEkH5fBLKD6VBXgvHH3ets8RhPxTqJJJS/XRzNY6Au8Gkc
	 ivQnFwNysqatgh60GaCv9XvgqeBvhdvVs/7J7AzBUS3ToSI3QfKbZ5kGFYffCzpOtv4Nz
	 ESg22oTKyim7fFJEXTKvvzSyOEUBAkItEsToHEpQLIM2woNFP1psoPfrESEfJll/o5X+2
	 y+2dZf4SJw8RI+VpInDOQOMeIViet7brWc4bMFEP+/pUIrExUC3UWH2NguhL+BFLgcZtu
	 jg7PXcBmDJ1rZzxi9UsW8oB+c5pQweU2jB731i2x9SzuoOKK8qsk7xYHVy9lKoZhvhQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793522702;
	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:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=HG4jSdlIW6vaY9/8cWolqytCrm6nbtCOV9zrhEfw6l0=;
	b=vjIx5KvZUQBPnoAZc6xTsztphmSEJWNGy5UXY/DTNU8Cf1AXcaxfLc6TYIjswkKEIUTG
	 09446OaDNL74Bz3SdDYfR5nInw0e2CZ/l/5Q75G+FS10tpAHBvPdkYWd8L+dypvtyB6u8
	 Cmc9DA/+8Sq5SfnZY9glJemVzOG2g5xDWIcjGX27MVxxkwnn2gtEeYSIMAg01T35H4W2p
	 4+pKu7iq8NtMnVj3ovf4ndKEh9fBkCzG1AOGjPu1v9aEXdTY+JpQI5qCqJ3itP0rk/ZFm
	 THY/A5AEPVuGo8d67fUMFDHektS4qcWUhRIVI78kSEgm4c9qkGXFXHbgXjammxnNapw==
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=kj+3thyF;
	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 A1694606A327;
	Sun,  1 Nov 2026 08:45:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=kj+3thyF
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=1793522701;
	b=2tXA4QpW3YoMh1pcx3kZjENGvitC3nYvNFwfqJDcTBV6hp+tSTyyC7FPsjV9W1wqtSTQ
	 Of5cTqViW//JhLcZ3D6/ndkfYNBtI4bjQMGPNpxZnbh+DoqOasijI+/qLsbISuO6MCVpw
	 N4QOnUyB1/XUWhsf0saTFg6h5fdx8Tl5A+YGll0VFRZP4MIwwJD3jeWhr1YHIkb2gTqA2
	 PfW4Gp9KZ/uqqGmncDgwnOq4TDrtTtA6rfmcP/Qo2xxhN6zLTYkCToG8gqe3elKQtp689
	 CTtCpLKQD+wQXSwmWqHMVtE72vy9TQbhqmWoNoZjexqbopLmr7vNKIVZo52GhPcIhRw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793522701;
	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:MIME-Version:Content-Transfer-Encoding;
	bh=HG4jSdlIW6vaY9/8cWolqytCrm6nbtCOV9zrhEfw6l0=;
	b=O76/jaafSTVSj3cMGW/2VQaZai9atMKChabSG+ePboYQX+ZOXuhSd/EO4He4jiJ41dfn
	 /P5fd+vXV0pp+jVHU4lmYQazwCM7SDBrCRVf/eo4pFVBWcUNx404KN97MoCbOfqev5TI4
	 1RwNQJezHqSjrwwBt3ppXXY0zPczOauLDLLbKFyPtm1vP9w+Rj3miIKWq+4l6SCbPcs5x
	 ouTutm9xSdcYbn7jB6+BsloNBv+Vu9fzExVAw1hBvCdxZ2Y//hrvkWMJqmpC1Syv+yczu
	 hnK1rNGFIbCaQJD+pBnK2J4kWe2gViz5cB8TDdWglyeeVygJiVhiQi4jSYUooyECWlw==
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=kj+3thyF;
	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 6A2B4606A324
	for <git@vger.kernel.org>; Sun,  1 Nov 2026 08:45:01 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6A2B4606A324
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-48dfc0421d9so1698009f8f.1
        for <git@vger.kernel.org>; Sun, 01 Nov 2026 01:45:01 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793522700; x=1794127500; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=HG4jSdlIW6vaY9/8cWolqytCrm6nbtCOV9zrhEfw6l0=;
        b=kj+3thyFLsEQT9p9mWdsLexgZ00Y6odaz4b9w8y+wcWBOFyXSboTuSX+vUignzDgO7
         wyo36OorFRf5fdRp6njU1fNn+TpJxgl8xy0MZUAgzzENZtRY2QyM6im6vdc3FOC+DnzP
         S3Kvoib8zI65XBoWJNabGfb2A/3BQ5HiFxgknfpDQVJfltro/zLBFECsmmEG1UAnOdoB
         slfwnD/k4ZwF+r/y3g0MR+mP0PTFQIV5hscSe5x2kpdSCKJH23tkpXW9J6lLSXR654yr
         YfGgu1cqz6u12Slvl8TV/+bYmfJC+ETBUWVjtpHuS2tEiq1b5hd8lGrhB8Zm7pSncB+3
         Xwjw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793522700; x=1794127500;
        h=content-transfer-encoding:mime-version: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=HG4jSdlIW6vaY9/8cWolqytCrm6nbtCOV9zrhEfw6l0=;
        b=eTl11wqZ7MEyJResuLMFygBstZhcYBv5Aso/P6SDoXt4Rwz9oBbhaCFq+D2FAOb4bj
         fkdC6xGxKyqlDlhHVGWiv/w05fnDYcLCYMdZX/jL8As1BkEHrU2ZhphxOI5z+wo3xsLT
         4j5I59btyjsto0MyFNroVYbgoB0HWknoYmQhQRV21g2SS2SV3FMgOv7plAvkKWA0LpVs
         YHR+9ewVUrwtD0y+sbiNuFOgRZ9h1lpUCU/iCtNljSe9sC/GwSFoqC31faY7JSNYC1OI
         ozlM1Z6Tc0XR3wnz4Ur49c4fhg7sn6YRr+UtTq9nC0J1zUxOYnDoUkcdlUhO0Eize1+t
         PP4w==
X-Gm-Message-State: APuU4Z+/DEHT2LSeCeCD3Gof0jBA+DY+gmgOOJVzI1zUVNKGwRgglEHu
	0Yj32OxZKfXPAMI+0/wicEQCggAGNsw7sQ85aRyPY7xIMBECeVu1C/gqe45UZNM4
X-Gm-Gg: AYBFou0aw0SqnLgD3oArV7cki/ncdTAfiXdtIvCkSZonihJVYgt+vohzLO2wY7vtrRC
	4IoUCh5/tN6UkwWU1zN91QFMcqnFCOGqEBe+ZysiUIEdXIF0P5VZb1EVTdhX7ojbGu2WxcxCCB9
	4VQEnTXVVz6nl9e+XRc/qpMBGQwE2UuGWHPT/jaKWTCGC2+FaIM1Lk3lYVmIFrt1qet8jEr2puQ
	EcG9urmXaRk50LXZeLsa0g5ZgKOjenQPIj1ika9B7y99iAgehGCNQlE8mopAfKHS1mGJOwGmKgQ
	G8uogB74JZhXktIkDKfifEKKpXpnOdUnnHD4uY/TMIdJAXKVceKzxNqX4m+3bY8WknWr7fNU6wP
	DbqD0kcbskhPXbzoxQteS1tA7XPkdU/9s5aku92qBHMlBN4ETEI0a+n5gRvtlCfqVgQD6CC6WI0
	S7JYDVK3Ub6n8nVTbIrCXHdXhHu/Pm+8vdJczAz0ugSzZct9l6tCGPL5EyZ6AXoll8z5UTmZK8R
	rI6RED3qldYwM5OfzpUUqtXL4/SZLbuboDxXBd5L7fGHULGhBhul50fcZZpQvLG/FrmgpGz0B7P
	8G/vhcZOHE+47H5l5i6dIsh2MO8SSByPVPmhj3VG+5VRCjmbx1Ea0I3XpglRlkw=
X-Received: by 2002:a5d:5f85:0:b0:487:21be:dcc6 with SMTP id ffacd0b85a97d-48e6e5008a9mr15314407f8f.21.1793522699594;
        Sun, 01 Nov 2026 01:44:59 -0700 (PDT)
X-Received: from ubuntu26lts1.example.com ([151.31.213.44])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b80ecbsm13330965f8f.35.2026.11.01.01.44.58
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sun, 01 Nov 2026 01:44:59 -0700 (PDT)
X-Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Elia Pinto <gitter.spiros@gmail.com>,
	Hamza Mahfooz <someguy@effective-light.com>,
	Junio C Hamano <gitster@pobox.com>,
	Ævar Arnfjörð Bjarmason <avarab@gmail.com>,
	Patrick Steinhardt <ps@pks.im>,
	Phillip Wood <phillip.wood@dunelm.org.uk>
X-Mailer: git-send-email 2.53.0
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