From: Jeff King Date: Thu, 09 Nov 2023 21:27:21 GMT Subject: Re: [PATCH 1/9] commit-graph: handle overflow in chunk_size checks Message-ID: <20231109212721.GA2728242@coredump.intra.peff.net> In-Reply-To: On Thu, Nov 09, 2023 at 04:13:17PM -0500, Taylor Blau wrote: > So everything in this patch makes sense and looks good to me. It does > make me think about the pair_chunk_expect() function that I proposed > elsewhere. I haven't yet read the rest of the series, so it may be a > totally useless direction by the end of this series ;-). Nope, it's not useless. But I do think it affects what we'd want the interface to look like, and... > But I wonder if the interface we want is something like: > > int pair_chunk_expect(struct chunkfile *cf, uint32_t chunk_id, > const unsigned char **p, > size_t record_size, size_t record_nr); > > So we can then grab the size of the chunk, divide it by "record_size" > and ensure that end up with "record_nr" as a result. ...this is exactly the direction I was thinking it would go. So if you got to the same place after reading my explanation, then hopefully something went right. ;) -Peff