]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
zip: read PKWARE Unix extra field metadata 3242/head
authordatauwu <datauwu@users.noreply.github.com>
Sun, 5 Jul 2026 05:22:03 +0000 (13:22 +0800)
committerdatauwu <datauwu@users.noreply.github.com>
Sun, 5 Jul 2026 05:27:29 +0000 (13:27 +0800)
Read the fixed metadata prefix of the PKWARE Unix extra field 0x000d.

The fixed portion contains atime, mtime, uid, and gid values. Require
the full 12-byte prefix before reading it, and leave the variable-length
data field unsupported for now.

libarchive/archive_read_support_format_zip.c

index 73b8a66408a273d96292fc384ca3165e64f08976..d0afaabc0532007b867489e5f1a996b7701b751e 100644 (file)
@@ -756,6 +756,22 @@ process_extra(struct archive_read *a, struct archive_entry *entry,
                         * on which file starts, but we don't handle
                         * multi-volume Zip files. */
                        break;
+               case 0x000d:
+                       /* PKWARE Unix Extra Field fixed metadata. */
+                       if (datasize >= 12) {
+                               zip_entry->atime = archive_le32dec(p + offset);
+                               zip_entry->mtime =
+                                   archive_le32dec(p + offset + 4);
+                               zip_entry->uid =
+                                   archive_le16dec(p + offset + 8);
+                               zip_entry->gid =
+                                   archive_le16dec(p + offset + 10);
+                               /*
+                                * APPNOTE.TXT also defines additional data after
+                                * this fixed metadata, depending on file type.
+                                */
+                       }
+                       break;
 #ifdef DEBUG
                case 0x0017:
                {