]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Only set the filename-present bit if we actually write the filename
authorTim Kientzle <kientzle@acm.org>
Sat, 13 Sep 2025 18:17:38 +0000 (11:17 -0700)
committerTim Kientzle <kientzle@acm.org>
Sat, 13 Sep 2025 18:17:38 +0000 (11:17 -0700)
libarchive/archive_write_add_filter_gzip.c

index 6784798d2d118143dd974c7cededec0a0b0481e6..47081cc30bd1c753097808c173f4734122f08c1a 100644 (file)
@@ -222,7 +222,7 @@ archive_compressor_gzip_open(struct archive_write_filter *f)
        data->compressed[0] = 0x1f; /* GZip signature bytes */
        data->compressed[1] = 0x8b;
        data->compressed[2] = 0x08; /* "Deflate" compression */
-       data->compressed[3] = data->original_filename == NULL ? 0 : 0x8;
+       data->compressed[3] = 0x00; /* Flags */
        if (data->timestamp >= 0) {
                time_t t = time(NULL);
                data->compressed[4] = (uint8_t)(t)&0xff;  /* Timestamp */
@@ -257,6 +257,7 @@ archive_compressor_gzip_open(struct archive_write_filter *f)
                        ofn_max_length = ofn_space_available;
                }
                if (ofn_length < ofn_max_length) {
+                       data->compressed[3] |= 0x8;
                        strcpy((char*)data->compressed + 10,
                               data->original_filename);
                        data->stream.next_out += ofn_length + 1;