@@ -14,6 +14,7 @@ struct chunk_info {
chunk_write_fn write_fn;
const void *start;
+ unsigned found:1;
};
struct chunkfile {
@@ -98,6 +99,7 @@ int read_table_of_contents(struct chunkfile *cf,
uint64_t toc_offset,
int toc_length)
{
+ int i;
uint32_t chunk_id;
const unsigned char *table_of_contents = mfile + toc_offset;
@@ -124,6 +126,14 @@ int read_table_of_contents(struct chunkfile *cf,
return -1;
}
+ for (i = 0; i < cf->chunks_nr; i++) {
+ if (cf->chunks[i].id == chunk_id) {
+ error(_("duplicate chunk ID %"PRIx32" found"),
+ chunk_id);
+ return -1;
+ }
+ }
+
cf->chunks[cf->chunks_nr].id = chunk_id;
cf->chunks[cf->chunks_nr].start = mfile + chunk_offset;
cf->chunks[cf->chunks_nr].size = next_chunk_offset - chunk_offset;