Re: [PATCH 08/20] midx: enforce chunk alignment on reading
From: Taylor Blau <hidden>
Date: 2023-10-11 15:01:21
From: Taylor Blau <hidden>
Date: 2023-10-11 15:01:21
On Mon, Oct 09, 2023 at 05:05:23PM -0400, Jeff King wrote:
@@ -120,6 +121,11 @@ int read_table_of_contents(struct chunkfile *cf, error(_("terminating chunk id appears earlier than expected")); return 1; } + if (chunk_offset % expected_alignment != 0) {
Oops, I missed this in my first read. I'm definitely nit-picking here,
but this should probably be:
if (chunk_offset % expected_alignment)
without the trailing "!= 0".
I don't have a strong preference here, since we are doing a comparison
of an arithmetic operation against an (un-)expected value. But I think
the CodingGuidelines would technically call this out of style...
+ error(_("chunk id %"PRIx32" not %d-byte aligned"),
+ chunk_id, expected_alignment);
+ return 1;
+ }
table_of_contents += CHUNK_TOC_ENTRY_SIZE;
next_chunk_offset = get_be64(table_of_contents + 4);Thanks, Taylor