Re: [PATCH v2 2/4] index-pack: use size_t in write_compressed()
- From
Elia Pinto <gitter.spiros@gmail.com>
- Date
- Nov 19, 2026, 06:05 UTC
- Message-ID
- <20261119060524.775205-2-gitter.spiros@gmail.com>
- In-Reply-To
- <av2pOWbYxNDYvS9p@pks.im>
On Wed, Nov 18, 2026 at 02:33:45PM +0100, Patrick Steinhardt wrote:
Show 7 quoted lines
> Hmm. It's probably an improvement, but the only caller does this: > > obj[1].idx.offset += write_compressed(f, buf, size); > > That's a `struct pack_idx_entry`, but its `offset` field is of type > `off_t`, which is signed. It feels sufficiently unlikely to ever > overflow, but should we verify regardless that we don't?
It costs little, and index-pack already does so for the data it reads: use() dies with "pack too large for current definition of off_t" when signed_add_overflows(consumed_bytes, bytes). I will do the same in append_obj_to_pack() in v3.
> Not even an EXPENSIVE one?
I can add one. It needs a local base of 4GiB and a thin pack with a delta against it. Writing that small delta by hand keeps pack-objects out of the picture, so only index-pack has to hold the base in memory. As it still takes a lot of memory and time, I would guard it with its own variable, like t5608 does with GIT_TEST_CLONE_2GB.
Thanks, Elia