git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/4] use size_t when parsing and checking objects

From
Simon Richter <simon.richter@hogyros.de>
Date
Oct 31, 2026, 17:06 UTC
Message-ID
<b6c3c811-cabf-4421-aab2-f6b4b30951c2@hogyros.de>
In-Reply-To
<cover.1793444420.git.gitter.spiros@gmail.com>
Hi,
On 10/31/26 20:09, Elia Pinto wrote:
Show 5 quoted lines
> 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.
Again, reminder that size_t is also 32 bit on 32-bit architectures, because size_t is used for the size of in-memory objects.
Anything that is on disk can have a size that only fits into an off_t, which is 64 bit if large file support is enabled, and 32 bit if it is not. If large file support is disabled, opening a file larger than 2 GB is supposed to fail (because you need to pass O_LARGEFILE, which is defined only if large file support is enabled), but there is a chance that an on-disk object got truncated, so that is not guaranteed.
So, use size_t only for in-memory data, but if you are reading data from disk piecewise, the total count of data processed needs to be an off_t.
   Simon
Previous: Elia PintoNext: Elia Pinto
Message 6 of 7 in “use size_t when parsing and checking objects”
  1. 0/4 use size_t when parsing and checking objectsElia Pinto, Oct 31, 2026
  2. 1/4 object-file: use size_t in check_object_signature()Elia Pinto, Oct 31, 2026
  3. 2/4 fsck: use size_t for the size of objects to checkElia Pinto, Oct 31, 2026
  4. 3/4 object, commit, tag: use size_t when parsing object buffersElia Pinto, Oct 31, 2026
  5. 4/4 tag, fmt-merge-msg, ref-filter: use size_t for message buffersElia Pinto, Oct 31, 2026
  6. Simon RichterOct 31, 2026
  7. Elia PintoOct 31, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.