]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
archive_read_next_header2: clean old entry data 1218/head
authorDmitry Torokhov <dtor@chromium.org>
Tue, 25 Jun 2019 22:17:52 +0000 (15:17 -0700)
committerDmitry Torokhov <dtor@chromium.org>
Wed, 26 Jun 2019 17:29:52 +0000 (10:29 -0700)
We need to clean old entry data in archive_read_next_header2 in Windows
and Posix disk readers to ensure consistent results. One possible
failure mode: sparse data from the previous entry is carried over to
next non-sparse file entry, causing it to be mishandled.

libarchive/archive_read_disk_posix.c
libarchive/archive_read_disk_windows.c

index c4df6c9436ba3b89d95f9faa07aadac133f36f54..87963c3c7c28b0b27ce298699f6af2ca7ee96a42 100644 (file)
@@ -1143,6 +1143,8 @@ _archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
                t->entry_fd = -1;
        }
 
+       archive_entry_clear(entry);
+
        for (;;) {
                r = next_entry(a, t, entry);
                if (t->entry_fd >= 0) {
index 4a5421f8f30effb8ec5c77345ed247ff2d35bc68..fdd376f9b945fe3a3bda6186d5e3a45765770faa 100644 (file)
@@ -1126,6 +1126,8 @@ _archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
                t->entry_fh = INVALID_HANDLE_VALUE;
        }
 
+       archive_entry_clear(entry);
+
        while ((r = next_entry(a, t, entry)) == ARCHIVE_RETRY)
                archive_entry_clear(entry);