All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elia Pinto <gitter.spiros@gmail.com>
To: git@vger.kernel.org
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Elia Pinto" <gitter.spiros@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"René Scharfe" <l.s.r@web.de>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: [PATCH 0/2] tree-walk: use size_t for tree sizes
Date: Fri, 30 Oct 2026 11:58:21 +0100	[thread overview]
Message-ID: <cover.1793357680.git.gitter.spiros@gmail.com> (raw)

struct tree_desc keeps the size of the tree buffer in an "unsigned
int", so a tree object of 4GiB or more is truncated on all platforms,
and struct tree adds another truncation on Windows, where "long" is
32 bits. The walk then sees only a prefix of the tree: it never reads
past the buffer, but when the cut falls between two entries the rest
of the tree silently disappears, both for commands like "git ls-tree"
and for the checks in fsck_tree().

Trees that large are not something one creates by accident, but they
can be crafted, and fsck is what is supposed to look at every entry
of them.

 1/2 moves struct tree_desc and the functions that set it up to
     size_t; this is the part that matters on all platforms.
 2/2 does the same for struct tree and parse_tree_buffer().

There is no test, as it would need a tree larger than 4GiB in memory;
1/2 describes how I checked the effect with a simulated 16-bit size.

This comes from the same search for truncated sizes as:

  https://lore.kernel.org/git/cover.1793352943.git.gitter.spiros@gmail.com/
  https://lore.kernel.org/git/cover.1793355390.git.gitter.spiros@gmail.com/

It is independent of both and merges cleanly with them. The series is
based on master (b9e5cff180).

Elia Pinto (2):
  tree-walk: use size_t for the size of tree buffers
  tree: use size_t for the size of parsed trees

 tree-walk.c | 14 +++++++-------
 tree-walk.h |  6 +++---
 tree.c      |  2 +-
 tree.h      |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)


base-commit: b9e5cff1803ab24582201ef059516eb16014b9d9
-- 
2.53.0


             reply	other threads:[~2026-10-30 10:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 10:58 Elia Pinto [this message]
2026-10-30 10:58 ` [PATCH 1/2] tree-walk: use size_t for the size of tree buffers Elia Pinto
2026-11-18  2:32   ` Junio C Hamano
2026-10-30 10:58 ` [PATCH 2/2] tree: use size_t for the size of parsed trees Elia Pinto
2026-11-18  3:47   ` Junio C Hamano
2026-11-17 21:42 ` [PATCH 0/2] tree-walk: use size_t for tree sizes Elia Pinto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1793357680.git.gitter.spiros@gmail.com \
    --to=gitter.spiros@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=ebiederm@xmission.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.