Re: [PATCH 11/20] midx: check size of revindex chunk
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Oct 11, 2023, 18:41 UTC
- Message-ID
- <ZSbsUQyA71AGMkhl@nand.local>
- In-Reply-To
- <20231009210533.GK3282181@coredump.intra.peff.net>
On Mon, Oct 09, 2023 at 05:05:33PM -0400, Jeff King wrote:
Show 10 quoted lines
> +static int can_use_midx_ridx_chunk(struct multi_pack_index *m)
> +{
> + if (!m->chunk_revindex)
> + return 0;
> + if (m->chunk_revindex_len != st_mult(sizeof(uint32_t), m->num_objects)) {
> + error(_("multi-pack-index reverse-index chunk is the wrong size"));
> + return 0;
> + }
> + return 1;
> +}This all looks good to me. I was going to suggest that it might be worth just NULL-ing out the chunk_revindex field here altogether. I think that we have some prior art for doing that in the commit-graph code (though I'd have to look to be sure...), but that's all within the same compilation unit.
Having the pack-revindex machinery NULL out a field of the MIDX structure feels icky to me, so I think that having a "can we use this function?" instead makes much more sense.
Thanks, Taylor