]> wimlib.net Git - wimlib/blobdiff - src/lookup_table.c
read_wim_lookup_table(): Make sure all resources get validated
[wimlib] / src / lookup_table.c
index 01f7383571c5f00899b6c7814f9f0e8323d398df..d42826dde7c09ea8b7365747dbfbec1c62d9cab7 100644 (file)
@@ -727,7 +727,6 @@ read_wim_lookup_table(WIMStruct *wim)
                        &((const struct wim_lookup_table_entry_disk*)buf)[i];
                struct wim_reshdr reshdr;
                u16 part_number;
-               struct wim_lookup_table_entry *duplicate_entry;
 
                /* Get the resource header  */
                get_wim_reshdr(&disk_entry->reshdr, &reshdr);
@@ -812,10 +811,10 @@ read_wim_lookup_table(WIMStruct *wim)
                 *   wimlib does not currently allow create WIMs with multiple
                 *   packed resources, as to remain compatible with WIMGAPI.)
                 */
-               if (likely(!cur_rspec) ||
-                   !(reshdr.flags & WIM_RESHDR_FLAG_PACKED_STREAMS) ||
-                     (reshdr.uncompressed_size == WIM_PACK_MAGIC_NUMBER &&
-                      cur_rspec->size_in_wim != 0))
+               if (likely(!(reshdr.flags & WIM_RESHDR_FLAG_PACKED_STREAMS))
+                   || !cur_rspec
+                   || (reshdr.uncompressed_size == WIM_PACK_MAGIC_NUMBER &&
+                       cur_rspec->size_in_wim != 0))
                {
                        /* Finish previous resource (if existent)  */
                        if (cur_rspec) {
@@ -947,8 +946,7 @@ read_wim_lookup_table(WIMStruct *wim)
                        /* Lookup table entry for a non-metadata stream.  */
 
                        /* Ignore this stream if it's a duplicate.  */
-                       duplicate_entry = lookup_stream(table, cur_entry->hash);
-                       if (duplicate_entry) {
+                       if (lookup_stream(table, cur_entry->hash)) {
                                num_duplicate_entries++;
                                goto free_cur_entry_and_continue;
                        }
@@ -976,7 +974,6 @@ read_wim_lookup_table(WIMStruct *wim)
                        cur_entry->offset_in_res = 0;
                        cur_entry->size = reshdr.uncompressed_size;
                        cur_entry->flags = reshdr.flags;
-                       cur_rspec = NULL;
                }
                continue;