- if (table->size != res_entry->size) {
- ERROR("Inconsistent integrity table sizes: Table header says "
- "%u bytes but resource entry says %"PRIu64" bytes",
- table->size, (u64)res_entry->size);
- ret = WIMLIB_ERR_INVALID_INTEGRITY_TABLE;
- goto out;
- }
-
- DEBUG("table->size = %u, table->num_entries = %u, "
- "table->chunk_size = %u",
- table->size, table->num_entries, table->chunk_size);
-
- expected_size = (u64)table->num_entries * SHA1_HASH_SIZE + 12;
-
- if (table->size != expected_size) {
- ERROR("Integrity table is %u bytes, but expected %"PRIu64" "
- "bytes to hold %u entries",
- table->size, expected_size, table->num_entries);
- ret = WIMLIB_ERR_INVALID_INTEGRITY_TABLE;
- goto out;
- }
-
- if (table->chunk_size == 0) {
- ERROR("Cannot use integrity chunk size of 0");
- ret = WIMLIB_ERR_INVALID_INTEGRITY_TABLE;
- goto out;
+ if (table->size != wim->hdr.integrity_table_reshdr.uncompressed_size ||
+ table->size != (u64)table->num_entries * SHA1_HASH_SIZE + 12 ||
+ table->chunk_size == 0 ||
+ table->num_entries != DIV_ROUND_UP(num_checked_bytes, table->chunk_size))
+ {
+ FREE(table);
+ goto invalid;