+ p = get_bytes(p, SHA1_HASH_SIZE, cur_entry->hash);
+
+ if (cur_entry->part_number != w->hdr.part_number) {
+ ERROR("A lookup table entry in part %hu of the WIM "
+ "points to part %hu",
+ w->hdr.part_number, cur_entry->part_number);
+ ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
+ goto out_free_cur_entry;
+ }
+
+ if (is_zero_hash(cur_entry->hash)) {
+ ERROR("The WIM lookup table contains an entry with a "
+ "SHA1 message digest of all 0's");
+ ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
+ goto out_free_cur_entry;
+ }
+
+ /* Ordinarily, no two streams should share the same SHA1 message
+ * digest. However, this constraint can be broken for metadata
+ * resources--- two identical images will have the same metadata
+ * resource, but their lookup table entries are not shared. */
+ duplicate_entry = __lookup_resource(table, cur_entry->hash);
+ if (duplicate_entry
+ && !((duplicate_entry->resource_entry.flags & WIM_RESHDR_FLAG_METADATA)
+ && cur_entry->resource_entry.flags & WIM_RESHDR_FLAG_METADATA))
+ {
+ #ifdef ENABLE_ERROR_MESSAGES
+ ERROR("The WIM lookup table contains two entries with the "
+ "same SHA1 message digest!");
+ ERROR("The first entry is:");
+ print_lookup_table_entry(duplicate_entry, stderr);
+ ERROR("The second entry is:");
+ print_lookup_table_entry(cur_entry, stderr);
+ #endif
+ ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
+ goto out_free_cur_entry;
+ }
+
+ if (!(cur_entry->resource_entry.flags & WIM_RESHDR_FLAG_COMPRESSED)
+ && (cur_entry->resource_entry.size !=
+ cur_entry->resource_entry.original_size))
+ {
+ #ifdef ENABLE_ERROR_MESSAGES
+ ERROR("Found uncompressed resource with original size "
+ "not the same as compressed size");
+ ERROR("The lookup table entry for the resource is as follows:");
+ print_lookup_table_entry(cur_entry, stderr);
+ #endif
+ ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
+ goto out_free_cur_entry;
+ }
+ if ((cur_entry->resource_entry.flags & WIM_RESHDR_FLAG_METADATA)
+ && cur_entry->refcnt != 1)
+ {
+ #ifdef ENABLE_ERROR_MESSAGES
+ ERROR("Found metadata resource with refcnt != 1:");
+ print_lookup_table_entry(cur_entry, stderr);
+ #endif
+ ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
+ goto out_free_cur_entry;
+ }