Git development
 help / color / mirror / Atom feed
* [PATCH 0/4] use size_t when parsing and checking objects
@ 2026-10-31 11:09 Elia Pinto
  2026-10-31 11:09 ` [PATCH 1/4] object-file: use size_t in check_object_signature() Elia Pinto
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Elia Pinto @ 2026-10-31 11:09 UTC (permalink / raw)
  To: git
  Cc: Johannes Schindelin, Elia Pinto, Junio C Hamano,
	Patrick Steinhardt, Jeff King, René Scharfe,
	brian m. carlson, Eric W. Biederman, Jiang Xin,
	Ævar Arnfjörð Bjarmason

This series continues the search for truncated sizes on platforms where
"long" is 32 bits (Windows). It covers the functions that parse, verify,
and check whole objects in memory: they take the size as an "unsigned
long", while their callers have a size_t, so above 4GiB the size gets
truncated.

Each patch addresses a specific component:
 - 1/4: a valid object reported as corrupt;
 - 2/4: fsck looks at only a prefix (e.g., .gitmodules);
 - 3/4: parsing of a prefix (with set_commit_buffer() now dying instead
   of caching a truncated size, as repo_get_commit_buffer() already
   does);
 - 4/4: "git tag -v" doesn't find the signature, plus the int index in
   copy_subject() on all platforms.

There are no out-of-bounds accesses; large objects only fail or are
handled as if they were shorter.

No tests are added because they would need objects over 4GiB in memory,
and they'd only detect the bug where long is 32 bits. I am happy to add
EXPENSIVE tests guarded by !LONG_IS_64BIT (like t1051) if reviewers
prefer.

Not covered here: the pack paths (index-pack, unpack-objects, pack
verification) still pass an "unsigned long" to fsck_object(); that's the
next series. The tree API (parse_tree_buffer(), init_tree_desc*()) is in
the tree-walk series:
  https://lore.kernel.org/git/cover.1793357680.git.gitter.spiros@gmail.com/
This series doesn't depend on the other series in flight and merges
cleanly with them. Based on master 50fe5cc63f.

Elia Pinto (4):
  object-file: use size_t in check_object_signature()
  fsck: use size_t for the size of objects to check
  object, commit, tag: use size_t when parsing object buffers
  tag, fmt-merge-msg, ref-filter: use size_t for message buffers

 commit.c              |  8 ++++----
 commit.h              |  6 +++---
 fmt-merge-msg.c       |  2 +-
 fsck.c                | 18 +++++++++---------
 fsck.h                |  6 +++---
 object-file-convert.c |  2 +-
 object-file.c         |  2 +-
 object-file.h         |  2 +-
 object.c              |  2 +-
 object.h              |  2 +-
 ref-filter.c          |  6 +++---
 tag.c                 |  4 ++--
 tag.h                 |  2 +-
 13 files changed, 31 insertions(+), 31 deletions(-)


base-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7
-- 
2.53.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-31 18:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-31 11:09 [PATCH 0/4] use size_t when parsing and checking objects Elia Pinto
2026-10-31 11:09 ` [PATCH 1/4] object-file: use size_t in check_object_signature() Elia Pinto
2026-10-31 11:09 ` [PATCH 2/4] fsck: use size_t for the size of objects to check Elia Pinto
2026-10-31 11:09 ` [PATCH 3/4] object, commit, tag: use size_t when parsing object buffers Elia Pinto
2026-10-31 11:10 ` [PATCH 4/4] tag, fmt-merge-msg, ref-filter: use size_t for message buffers Elia Pinto
2026-10-31 17:06 ` [PATCH 0/4] use size_t when parsing and checking objects Simon Richter
2026-10-31 18:37   ` Elia Pinto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox