* "chunk table" provides the offset, in bytes relative to the end of the
* chunk table, of the start of each compressed chunk, except for the first
* chunk which is omitted as it always has an offset of 0. Chunk table
* "chunk table" provides the offset, in bytes relative to the end of the
* chunk table, of the start of each compressed chunk, except for the first
* chunk which is omitted as it always has an offset of 0. Chunk table
- * entries are 32-bit for resources <= 4 GiB uncompressed and 64-bit for
- * resources > 4 GiB uncompressed.
+ * entries are 32-bit for resources < 4 GiB uncompressed and 64-bit for
+ * resources >= 4 GiB uncompressed.
*
* - Solid resource format (distinguished by the use of WIM_RESHDR_FLAG_SOLID
* instead of WIM_RESHDR_FLAG_COMPRESSED): similar to the original format, but
*
* - Solid resource format (distinguished by the use of WIM_RESHDR_FLAG_SOLID
* instead of WIM_RESHDR_FLAG_COMPRESSED): similar to the original format, but
if (alt_chunk_table) {
/* The alternate chunk table contains chunk sizes, not
* offsets, so we always must read all preceding entries
* in order to determine offsets. */
first_chunk_entry_to_read = 0;
if (alt_chunk_table) {
/* The alternate chunk table contains chunk sizes, not
* offsets, so we always must read all preceding entries
* in order to determine offsets. */
first_chunk_entry_to_read = 0;
- if (read_start_chunk == 0)
+ num_chunk_entries_to_read = last_needed_chunk - read_start_chunk + 1;
+
+ /* The first chunk has no explicit chunk table entry. */
+ if (read_start_chunk == 0) {
+ num_chunk_entries_to_read--;
- if (last_needed_chunk == 0)
- last_chunk_entry_to_read = 0;
- else
- last_chunk_entry_to_read = last_needed_chunk - 1;
-
+ /* Unless we're reading the final chunk of the resource,
+ * we need the offset of the chunk following the last
+ * needed chunk so that the compressed size of the last
+ * needed chunk can be computed. */
const u64 chunk_offsets_alloc_size =
max(num_chunk_entries_to_read,
num_needed_chunk_offsets) * sizeof(chunk_offsets[0]);
const u64 chunk_offsets_alloc_size =
max(num_chunk_entries_to_read,
num_needed_chunk_offsets) * sizeof(chunk_offsets[0]);
- [BLOB_IN_WINNT_FILE_ON_DISK] = read_winnt_stream_prefix,
- [BLOB_WIN32_ENCRYPTED] = read_win32_encrypted_file_prefix,
+ [BLOB_IN_WINDOWS_FILE] = read_windows_file_prefix,
" Path: \"%"TS"\"\n"
" Expected SHA-1: %"TS"\n"
" Actual SHA-1: %"TS"\n",
" Path: \"%"TS"\"\n"
" Expected SHA-1: %"TS"\n"
" Actual SHA-1: %"TS"\n",
return WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED;
} else if (blob->blob_location == BLOB_IN_WIM) {
const struct wim_resource_descriptor *rdesc = blob->rdesc;
return WIMLIB_ERR_CONCURRENT_MODIFICATION_DETECTED;
} else if (blob->blob_location == BLOB_IN_WIM) {
const struct wim_resource_descriptor *rdesc = blob->rdesc;