]> wimlib.net Git - wimlib/blobdiff - src/integrity.c
imagex capture and append consolidation
[wimlib] / src / integrity.c
index e310716130bfa79084a0a6b789286d623441a8c6..70ff7ffe991a92f0c561e14d78b466ac1269fcc2 100644 (file)
  * This file is part of wimlib, a library for working with WIM files.
  *
  * wimlib is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
+ * terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
  * any later version.
  *
  * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more
  * details.
  *
- * You should have received a copy of the GNU Lesser General Public License
+ * You should have received a copy of the GNU General Public License
  * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
@@ -49,7 +49,7 @@ static int verify_integrity(FILE *fp, u64 num_bytes, u32 chunk_size,
                            const u8 *sha1sums, int show_progress,
                            int *status)
 {
-       char  *chunk_buf;
+       u8    *chunk_buf;
        u8     resblock[SHA1_HASH_SIZE];
        u64    bytes_remaining;
        size_t bytes_to_read;
@@ -117,7 +117,6 @@ int check_wim_integrity(WIMStruct *w, int show_progress, int *status)
 {
 
        struct resource_entry *res_entry;
-       int ctype;
        u8 *buf = NULL;
        int ret;
        u32 integrity_table_size;
@@ -135,11 +134,14 @@ int check_wim_integrity(WIMStruct *w, int show_progress, int *status)
                *status = WIM_INTEGRITY_NONEXISTENT;
                return 0;
        }
-       ctype = wim_resource_compression_type(w, res_entry);
        if (res_entry->original_size < 12) {
                ERROR("Integrity table is too short");
                return WIMLIB_ERR_INVALID_INTEGRITY_TABLE;
        }
+       if (res_entry->flags & WIM_RESHDR_FLAG_COMPRESSED) {
+               ERROR("Didn't expect a compressed integrity table");
+               return WIMLIB_ERR_INVALID_INTEGRITY_TABLE;
+       }
 
        /* Read the integrity table into memory. */
        buf = MALLOC(res_entry->original_size);
@@ -149,15 +151,14 @@ int check_wim_integrity(WIMStruct *w, int show_progress, int *status)
                ret = WIMLIB_ERR_NOMEM;
                goto out;
        }
-       ret = read_full_resource(w->fp, res_entry->size,
-                                res_entry->original_size,
-                                res_entry->offset, ctype, buf);
+       ret = read_uncompressed_resource(w->fp, res_entry->offset,
+                                        res_entry->original_size, buf);
        if (ret != 0) {
                ERROR("Failed to read integrity table (size = %"PRIu64", "
                      "original_size = %"PRIu64", offset = "
-                     "%"PRIu64", ctype = %d",
+                     "%"PRIu64")",
                      (u64)res_entry->size, res_entry->original_size,
-                     res_entry->offset, ctype);
+                     res_entry->offset);
                goto out;
        }
 
@@ -249,7 +250,7 @@ int write_integrity_table(FILE *out, u64 end_header_offset,
        u64   bytes_remaining;
        u8   *buf;
        u8   *p;
-       char *chunk_buf;
+       u8   *chunk_buf;
        u32   num_entries;
        u32   integrity_table_size;
        int   ret;