finish_write(): Don't use old integrity table if already overwritten
authorEric Biggers <ebiggers3@gmail.com>
Sat, 14 Jun 2014 04:46:58 +0000 (23:46 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 14 Jun 2014 04:54:51 +0000 (23:54 -0500)
When updating a WIM in-place without modifying the lookup table, the new
XML data will spill into the old integrity table if the new XML data is
longer than the old XML data.  Temporarily fix this by not using the old
integrity table in this case.

src/write.c

index 5bca038a61afd909b5d868391ed21ebf37d49a5c..9acdffac84a147694057f6b1212090352e7a27ec 100644 (file)
@@ -2350,6 +2350,15 @@ finish_write(WIMStruct *wim, int image, int write_flags,
                if (!(write_flags & WIMLIB_WRITE_FLAG_REUSE_INTEGRITY_TABLE))
                        old_lookup_table_end = 0;
 
+               if (wim->hdr.integrity_table_reshdr.offset_in_wim <
+                   wim->hdr.xml_data_reshdr.offset_in_wim +
+                       wim->hdr.xml_data_reshdr.size_in_wim)
+               {
+                       /* Old integrity table was partially overwritten by the
+                        * XML data.  */
+                       old_lookup_table_end = 0;
+               }
+
                new_lookup_table_end = wim->hdr.lookup_table_reshdr.offset_in_wim +
                                       wim->hdr.lookup_table_reshdr.size_in_wim;