Re: [PATCH 1/3] packfile: factor out --pack_header argument parsing
- From
Jeff King <peff@peff.net>
- Date
- Jan 18, 2025, 09:23 UTC
- Message-ID
- <20250118092351.GB3474411@coredump.intra.peff.net>
- In-Reply-To
- <xmqqo705hxfz.fsf@gitster.g>
On Fri, Jan 17, 2025 at 02:45:04PM -0800, Junio C Hamano wrote:
Show 12 quoted lines
> Jeff King <peff@peff.net> writes:
>
> > } else if (starts_with(arg, "--pack_header=")) {
> > - struct pack_header *hdr;
> > - char *c;
> > -
> > - hdr = (struct pack_header *)input_buffer;
> > - hdr->hdr_signature = htonl(PACK_SIGNATURE);
> > - hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10));
>
> Interesting. So the file-scope static input_buffer[] sits in the
> BSS and happens to be well aligned not to cause the problem, but ...I suspect it _is_ a problem, but either:
- The OP's test case was small enough to trigger unpack-objects, not
index-pack. Possibly:git index-pack --stdin --pack_header=2,2 <no-header.pack
would fail for them.
- We simply got lucky with alignment based on the other things in BSS,
the whim of the compiler, etc. But it is an accident waiting to
happen.-Peff