]> wimlib.net Git - wimlib/blobdiff - src/resource.c
Align security data correctly
[wimlib] / src / resource.c
index 3c573f1c9131d4cfb0af8f1ff8e68b87964366b0..0e55725d921e07679a0ef88bc37c3e6038a7976e 100644 (file)
@@ -882,7 +882,9 @@ static int write_wim_resource(struct lookup_table_entry *lte,
                }
        }
 
-       if (new_compressed_size > original_size) {
+       if (new_compressed_size >= original_size &&
+           out_ctype != WIM_COMPRESSION_TYPE_NONE && !raw)
+       {
                /* Oops!  We compressed the resource to larger than the original
                 * size.  Write the resource uncompressed instead. */
                if (fseeko(out_fp, file_offset, SEEK_SET) != 0) {
@@ -1254,7 +1256,8 @@ int write_metadata_resource(WIMStruct *w)
         * - plus 8 bytes for an end-of-directory entry following the root
         *   dentry (shouldn't really be needed, but just in case...)
         */
-       subdir_offset = ((sd->total_length + 7) & ~7) + dentry_total_length(root) + 8;
+       subdir_offset = ((sd->total_length + 7) & ~7) +
+                       dentry_correct_total_length(root) + 8;
 
        /* Calculate the subdirectory offsets for the entire dentry tree. */
        calculate_subdir_offsets(root, &subdir_offset);