2 * Copyright (c) 2004 Tim Kientzle
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #include "archive_platform.h"
27 __FBSDID("$FreeBSD$");
40 /* Hmmm... This is necessary, but means that we can't correctly extract
41 * even uncompressed entries on platforms that lack zlib. */
42 #define crc32(crc, buf, len) (unsigned long)0
46 #include "archive_entry.h"
47 #include "archive_private.h"
48 #include "archive_read_private.h"
49 #include "archive_endian.h"
52 /* entry_bytes_remaining is the number of bytes we expect. */
53 int64_t entry_bytes_remaining;
56 /* These count the number of bytes actually read for the entry. */
57 int64_t entry_compressed_bytes_read;
58 int64_t entry_uncompressed_bytes_read;
60 /* Running CRC32 of the decompressed data */
61 unsigned long entry_crc32;
67 const char * compression_name;
75 /* Flags to mark progress of decompression. */
80 ssize_t filename_length;
82 int64_t uncompressed_size;
83 int64_t compressed_size;
85 unsigned char *uncompressed_buffer;
86 size_t uncompressed_buffer_size;
92 struct archive_string pathname;
93 struct archive_string extra;
97 #define ZIP_LENGTH_AT_END 8
99 struct zip_file_header {
106 char compressed_size[4];
107 char uncompressed_size[4];
108 char filename_length[2];
109 char extra_length[2];
112 static const char *compression_names[] = {
124 static int archive_read_format_zip_bid(struct archive_read *);
125 static int archive_read_format_zip_cleanup(struct archive_read *);
126 static int archive_read_format_zip_read_data(struct archive_read *,
127 const void **, size_t *, off_t *);
128 static int archive_read_format_zip_read_data_skip(struct archive_read *a);
129 static int archive_read_format_zip_read_header(struct archive_read *,
130 struct archive_entry *);
131 static int zip_read_data_deflate(struct archive_read *a, const void **buff,
132 size_t *size, off_t *offset);
133 static int zip_read_data_none(struct archive_read *a, const void **buff,
134 size_t *size, off_t *offset);
135 static int zip_read_file_header(struct archive_read *a,
136 struct archive_entry *entry, struct zip *zip);
137 static time_t zip_time(const char *);
138 static void process_extra(const void* extra, struct zip* zip);
141 archive_read_support_format_zip(struct archive *_a)
143 struct archive_read *a = (struct archive_read *)_a;
147 zip = (struct zip *)malloc(sizeof(*zip));
149 archive_set_error(&a->archive, ENOMEM, "Can't allocate zip data");
150 return (ARCHIVE_FATAL);
152 memset(zip, 0, sizeof(*zip));
154 r = __archive_read_register_format(a,
157 archive_read_format_zip_bid,
159 archive_read_format_zip_read_header,
160 archive_read_format_zip_read_data,
161 archive_read_format_zip_read_data_skip,
162 archive_read_format_zip_cleanup);
171 archive_read_format_zip_bid(struct archive_read *a)
175 ssize_t bytes_avail, offset;
177 if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
181 * Bid of 30 here is: 16 bits for "PK",
182 * next 16-bit field has four options (-2 bits).
185 if (p[0] == 'P' && p[1] == 'K') {
186 if ((p[2] == '\001' && p[3] == '\002')
187 || (p[2] == '\003' && p[3] == '\004')
188 || (p[2] == '\005' && p[3] == '\006')
189 || (p[2] == '\007' && p[3] == '\010')
190 || (p[2] == '0' && p[3] == '0'))
195 * Attempt to handle self-extracting archives
196 * by noting a PE header and searching forward
197 * up to 128k for a 'PK\003\004' marker.
199 if (p[0] == 'M' && p[1] == 'Z') {
201 * TODO: Optimize by initializing 'offset' to an
202 * estimate of the likely start of the archive data
203 * based on values in the PE header. Note that we
204 * don't need to be exact, but we mustn't skip too
205 * far. The search below will compensate if we
209 while (offset < 124000) {
210 /* Get 4k of data beyond where we stopped. */
211 buff = __archive_read_ahead(a, offset + 4096,
213 if (bytes_avail < offset + 1)
215 p = (const char *)buff + offset;
216 while (p + 9 < (const char *)buff + bytes_avail) {
217 if (p[0] == 'P' && p[1] == 'K' /* signature */
218 && p[2] == 3 && p[3] == 4 /* File entry */
219 && p[8] == 8 /* compression == deflate */
220 && p[9] == 0 /* High byte of compression */
227 offset = p - (const char *)buff;
235 * Search forward for a "PK\003\004" file header. This handles the
236 * case of self-extracting archives, where there is an executable
237 * prepended to the ZIP archive.
240 skip_sfx(struct archive_read *a)
248 * TODO: We should be able to skip forward by a bunch
249 * by lifting some values from the PE header. We don't
250 * need to be exact (we're still going to search forward
251 * to find the header), but it will speed things up and
252 * reduce the chance of a false positive.
255 h = __archive_read_ahead(a, 4, &bytes);
257 return (ARCHIVE_FATAL);
262 * Scan ahead until we find something that looks
263 * like the zip header.
268 /* TODO: Additional verification here. */
269 if (memcmp("PK\003\004", p, 4) == 0) {
270 skip = p - (const char *)h;
271 __archive_read_consume(a, skip);
276 case '\003': p += 1; break;
277 case 'K': p += 2; break;
278 case 'P': p += 3; break;
279 default: p += 4; break;
282 skip = p - (const char *)h;
283 __archive_read_consume(a, skip);
288 archive_read_format_zip_read_header(struct archive_read *a,
289 struct archive_entry *entry)
292 const char *signature;
294 int r = ARCHIVE_OK, r1;
296 a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
297 if (a->archive.archive_format_name == NULL)
298 a->archive.archive_format_name = "ZIP";
300 zip = (struct zip *)(a->format->data);
301 zip->decompress_init = 0;
302 zip->end_of_entry = 0;
303 zip->entry_uncompressed_bytes_read = 0;
304 zip->entry_compressed_bytes_read = 0;
305 zip->entry_crc32 = crc32(0, NULL, 0);
306 if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
307 return (ARCHIVE_FATAL);
309 signature = (const char *)h;
310 if (signature[0] == 'M' && signature[1] == 'Z') {
311 /* This is an executable? Must be self-extracting... */
313 if (r < ARCHIVE_WARN)
315 if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
316 return (ARCHIVE_FATAL);
317 signature = (const char *)h;
320 if (signature[0] != 'P' || signature[1] != 'K') {
321 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
323 return (ARCHIVE_FATAL);
327 * "PK00" signature is used for "split" archives that
328 * only have a single segment. This means we can just
329 * skip the PK00; the first real file header should follow.
331 if (signature[2] == '0' && signature[3] == '0') {
332 __archive_read_consume(a, 4);
333 if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
334 return (ARCHIVE_FATAL);
335 signature = (const char *)h;
336 if (signature[0] != 'P' || signature[1] != 'K') {
337 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
339 return (ARCHIVE_FATAL);
343 if (signature[2] == '\001' && signature[3] == '\002') {
344 /* Beginning of central directory. */
345 return (ARCHIVE_EOF);
348 if (signature[2] == '\003' && signature[3] == '\004') {
349 /* Regular file entry. */
350 r1 = zip_read_file_header(a, entry, zip);
351 if (r1 != ARCHIVE_OK)
356 if (signature[2] == '\005' && signature[3] == '\006') {
357 /* End-of-archive record. */
358 return (ARCHIVE_EOF);
361 if (signature[2] == '\007' && signature[3] == '\010') {
363 * We should never encounter this record here;
364 * see ZIP_LENGTH_AT_END handling below for details.
366 archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
367 "Bad ZIP file: Unexpected end-of-entry record");
368 return (ARCHIVE_FATAL);
371 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
372 "Damaged ZIP file or unsupported format variant (%d,%d)",
373 signature[2], signature[3]);
374 return (ARCHIVE_FATAL);
378 zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
381 const struct zip_file_header *p;
384 if ((p = __archive_read_ahead(a, sizeof *p, NULL)) == NULL) {
385 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
386 "Truncated ZIP file header");
387 return (ARCHIVE_FATAL);
390 zip->version = p->version[0];
391 zip->system = p->version[1];
392 zip->flags = archive_le16dec(p->flags);
393 zip->compression = archive_le16dec(p->compression);
394 if (zip->compression <
395 sizeof(compression_names)/sizeof(compression_names[0]))
396 zip->compression_name = compression_names[zip->compression];
398 zip->compression_name = "??";
399 zip->mtime = zip_time(p->timedate);
405 zip->crc32 = archive_le32dec(p->crc32);
406 zip->filename_length = archive_le16dec(p->filename_length);
407 zip->extra_length = archive_le16dec(p->extra_length);
408 zip->uncompressed_size = archive_le32dec(p->uncompressed_size);
409 zip->compressed_size = archive_le32dec(p->compressed_size);
411 __archive_read_consume(a, sizeof(struct zip_file_header));
414 /* Read the filename. */
415 if ((h = __archive_read_ahead(a, zip->filename_length, NULL)) == NULL) {
416 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
417 "Truncated ZIP file header");
418 return (ARCHIVE_FATAL);
420 if (archive_string_ensure(&zip->pathname, zip->filename_length) == NULL)
421 __archive_errx(1, "Out of memory");
422 archive_strncpy(&zip->pathname, h, zip->filename_length);
423 __archive_read_consume(a, zip->filename_length);
424 archive_entry_set_pathname(entry, zip->pathname.s);
426 if (zip->pathname.s[archive_strlen(&zip->pathname) - 1] == '/')
427 zip->mode = AE_IFDIR | 0777;
429 zip->mode = AE_IFREG | 0777;
431 /* Read the extra data. */
432 if ((h = __archive_read_ahead(a, zip->extra_length, NULL)) == NULL) {
433 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
434 "Truncated ZIP file header");
435 return (ARCHIVE_FATAL);
437 process_extra(h, zip);
438 __archive_read_consume(a, zip->extra_length);
440 /* Populate some additional entry fields: */
441 archive_entry_set_mode(entry, zip->mode);
442 archive_entry_set_uid(entry, zip->uid);
443 archive_entry_set_gid(entry, zip->gid);
444 archive_entry_set_mtime(entry, zip->mtime, 0);
445 archive_entry_set_ctime(entry, zip->ctime, 0);
446 archive_entry_set_atime(entry, zip->atime, 0);
447 /* Set the size only if it's meaningful. */
448 if (0 == (zip->flags & ZIP_LENGTH_AT_END))
449 archive_entry_set_size(entry, zip->uncompressed_size);
451 zip->entry_bytes_remaining = zip->compressed_size;
452 zip->entry_offset = 0;
454 /* If there's no body, force read_data() to return EOF immediately. */
455 if (0 == (zip->flags & ZIP_LENGTH_AT_END)
456 && zip->entry_bytes_remaining < 1)
457 zip->end_of_entry = 1;
459 /* Set up a more descriptive format name. */
460 sprintf(zip->format_name, "ZIP %d.%d (%s)",
461 zip->version / 10, zip->version % 10,
462 zip->compression_name);
463 a->archive.archive_format_name = zip->format_name;
468 /* Convert an MSDOS-style date/time into Unix-style time. */
470 zip_time(const char *p)
475 msTime = (0xff & (unsigned)p[0]) + 256 * (0xff & (unsigned)p[1]);
476 msDate = (0xff & (unsigned)p[2]) + 256 * (0xff & (unsigned)p[3]);
478 memset(&ts, 0, sizeof(ts));
479 ts.tm_year = ((msDate >> 9) & 0x7f) + 80; /* Years since 1900. */
480 ts.tm_mon = ((msDate >> 5) & 0x0f) - 1; /* Month number. */
481 ts.tm_mday = msDate & 0x1f; /* Day of month. */
482 ts.tm_hour = (msTime >> 11) & 0x1f;
483 ts.tm_min = (msTime >> 5) & 0x3f;
484 ts.tm_sec = (msTime << 1) & 0x3e;
490 archive_read_format_zip_read_data(struct archive_read *a,
491 const void **buff, size_t *size, off_t *offset)
496 zip = (struct zip *)(a->format->data);
499 * If we hit end-of-entry last time, clean up and return
500 * ARCHIVE_EOF this time.
502 if (zip->end_of_entry) {
503 *offset = zip->entry_uncompressed_bytes_read;
506 return (ARCHIVE_EOF);
509 switch(zip->compression) {
510 case 0: /* No compression. */
511 r = zip_read_data_none(a, buff, size, offset);
513 case 8: /* Deflate compression. */
514 r = zip_read_data_deflate(a, buff, size, offset);
516 default: /* Unsupported compression. */
520 /* Return a warning. */
521 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
522 "Unsupported ZIP compression method (%s)",
523 zip->compression_name);
524 if (zip->flags & ZIP_LENGTH_AT_END) {
526 * ZIP_LENGTH_AT_END requires us to
527 * decompress the entry in order to
528 * skip it, but we don't know this
529 * compression method, so we give up.
533 /* We can't decompress this entry, but we will
534 * be able to skip() it and try the next entry. */
541 /* Update checksum */
544 crc32(zip->entry_crc32, *buff, *size);
545 /* If we hit the end, swallow any end-of-data marker. */
546 if (zip->end_of_entry) {
547 if (zip->flags & ZIP_LENGTH_AT_END) {
550 if ((p = __archive_read_ahead(a, 16, NULL)) == NULL) {
551 archive_set_error(&a->archive,
552 ARCHIVE_ERRNO_FILE_FORMAT,
553 "Truncated ZIP end-of-file record");
554 return (ARCHIVE_FATAL);
556 zip->crc32 = archive_le32dec(p + 4);
557 zip->compressed_size = archive_le32dec(p + 8);
558 zip->uncompressed_size = archive_le32dec(p + 12);
559 __archive_read_consume(a, 16);
561 /* Check file size, CRC against these values. */
562 if (zip->compressed_size != zip->entry_compressed_bytes_read) {
563 archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
564 "ZIP compressed data is wrong size");
565 return (ARCHIVE_WARN);
567 /* Size field only stores the lower 32 bits of the actual size. */
568 if ((zip->uncompressed_size & UINT32_MAX)
569 != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) {
570 archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
571 "ZIP uncompressed data is wrong size");
572 return (ARCHIVE_WARN);
574 /* Check computed CRC against header */
575 if (zip->crc32 != zip->entry_crc32) {
576 archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
577 "ZIP bad CRC: 0x%lx should be 0x%lx",
578 zip->entry_crc32, zip->crc32);
579 return (ARCHIVE_WARN);
583 /* Return EOF immediately if this is a non-regular file. */
584 if (AE_IFREG != (zip->mode & AE_IFMT))
585 return (ARCHIVE_EOF);
590 * Read "uncompressed" data. According to the current specification,
591 * if ZIP_LENGTH_AT_END is specified, then the size fields in the
592 * initial file header are supposed to be set to zero. This would, of
593 * course, make it impossible for us to read the archive, since we
594 * couldn't determine the end of the file data. Info-ZIP seems to
595 * include the real size fields both before and after the data in this
596 * case (the CRC only appears afterwards), so this works as you would
599 * Returns ARCHIVE_OK if successful, ARCHIVE_FATAL otherwise, sets
600 * zip->end_of_entry if it consumes all of the data.
603 zip_read_data_none(struct archive_read *a, const void **buff,
604 size_t *size, off_t *offset)
609 zip = (struct zip *)(a->format->data);
611 if (zip->entry_bytes_remaining == 0) {
614 *offset = zip->entry_offset;
615 zip->end_of_entry = 1;
619 * Note: '1' here is a performance optimization.
620 * Recall that the decompression layer returns a count of
621 * available bytes; asking for more than that forces the
622 * decompressor to combine reads by copying data.
624 *buff = __archive_read_ahead(a, 1, &bytes_avail);
625 if (bytes_avail <= 0) {
626 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
627 "Truncated ZIP file data");
628 return (ARCHIVE_FATAL);
630 if (bytes_avail > zip->entry_bytes_remaining)
631 bytes_avail = zip->entry_bytes_remaining;
632 __archive_read_consume(a, bytes_avail);
634 *offset = zip->entry_offset;
635 zip->entry_offset += *size;
636 zip->entry_bytes_remaining -= *size;
637 zip->entry_uncompressed_bytes_read += *size;
638 zip->entry_compressed_bytes_read += *size;
644 zip_read_data_deflate(struct archive_read *a, const void **buff,
645 size_t *size, off_t *offset)
649 const void *compressed_buff;
652 zip = (struct zip *)(a->format->data);
654 /* If the buffer hasn't been allocated, allocate it now. */
655 if (zip->uncompressed_buffer == NULL) {
656 zip->uncompressed_buffer_size = 32 * 1024;
657 zip->uncompressed_buffer
658 = (unsigned char *)malloc(zip->uncompressed_buffer_size);
659 if (zip->uncompressed_buffer == NULL) {
660 archive_set_error(&a->archive, ENOMEM,
661 "No memory for ZIP decompression");
662 return (ARCHIVE_FATAL);
666 /* If we haven't yet read any data, initialize the decompressor. */
667 if (!zip->decompress_init) {
668 if (zip->stream_valid)
669 r = inflateReset(&zip->stream);
671 r = inflateInit2(&zip->stream,
672 -15 /* Don't check for zlib header */);
674 archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
675 "Can't initialize ZIP decompression.");
676 return (ARCHIVE_FATAL);
678 /* Stream structure has been set up. */
679 zip->stream_valid = 1;
680 /* We've initialized decompression for this stream. */
681 zip->decompress_init = 1;
685 * Note: '1' here is a performance optimization.
686 * Recall that the decompression layer returns a count of
687 * available bytes; asking for more than that forces the
688 * decompressor to combine reads by copying data.
690 compressed_buff = __archive_read_ahead(a, 1, &bytes_avail);
691 if (bytes_avail <= 0) {
692 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
693 "Truncated ZIP file body");
694 return (ARCHIVE_FATAL);
698 * A bug in zlib.h: stream.next_in should be marked 'const'
699 * but isn't (the library never alters data through the
700 * next_in pointer, only reads it). The result: this ugly
701 * cast to remove 'const'.
703 zip->stream.next_in = (Bytef *)(uintptr_t)(const void *)compressed_buff;
704 zip->stream.avail_in = bytes_avail;
705 zip->stream.total_in = 0;
706 zip->stream.next_out = zip->uncompressed_buffer;
707 zip->stream.avail_out = zip->uncompressed_buffer_size;
708 zip->stream.total_out = 0;
710 r = inflate(&zip->stream, 0);
715 zip->end_of_entry = 1;
718 archive_set_error(&a->archive, ENOMEM,
719 "Out of memory for ZIP decompression");
720 return (ARCHIVE_FATAL);
722 archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
723 "ZIP decompression failed (%d)", r);
724 return (ARCHIVE_FATAL);
727 /* Consume as much as the compressor actually used. */
728 bytes_avail = zip->stream.total_in;
729 __archive_read_consume(a, bytes_avail);
730 zip->entry_bytes_remaining -= bytes_avail;
731 zip->entry_compressed_bytes_read += bytes_avail;
733 *offset = zip->entry_offset;
734 *size = zip->stream.total_out;
735 zip->entry_uncompressed_bytes_read += *size;
736 *buff = zip->uncompressed_buffer;
737 zip->entry_offset += *size;
742 zip_read_data_deflate(struct archive_read *a, const void **buff,
743 size_t *size, off_t *offset)
748 archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
749 "libarchive compiled without deflate support (no libz)");
750 return (ARCHIVE_FATAL);
755 archive_read_format_zip_read_data_skip(struct archive_read *a)
758 const void *buff = NULL;
761 zip = (struct zip *)(a->format->data);
763 /* If we've already read to end of data, we're done. */
764 if (zip->end_of_entry)
768 * If the length is at the end, we have no choice but
769 * to decompress all the data to find the end marker.
771 if (zip->flags & ZIP_LENGTH_AT_END) {
776 r = archive_read_format_zip_read_data(a, &buff,
778 } while (r == ARCHIVE_OK);
783 * If the length is at the beginning, we can skip the
784 * compressed data much more quickly.
786 bytes_skipped = __archive_read_skip(a, zip->entry_bytes_remaining);
787 if (bytes_skipped < 0)
788 return (ARCHIVE_FATAL);
790 /* This entry is finished and done. */
791 zip->end_of_entry = 1;
796 archive_read_format_zip_cleanup(struct archive_read *a)
800 zip = (struct zip *)(a->format->data);
802 if (zip->stream_valid)
803 inflateEnd(&zip->stream);
805 free(zip->uncompressed_buffer);
806 archive_string_free(&(zip->pathname));
807 archive_string_free(&(zip->extra));
809 (a->format->data) = NULL;
814 * The extra data is stored as a list of
815 * id1+size1+data1 + id2+size2+data2 ...
816 * triplets. id and size are 2 bytes each.
819 process_extra(const void* extra, struct zip* zip)
822 const char *p = (const char *)extra;
823 while (offset < zip->extra_length - 4)
825 unsigned short headerid = archive_le16dec(p + offset);
826 unsigned short datasize = archive_le16dec(p + offset + 2);
828 if (offset + datasize > zip->extra_length)
831 fprintf(stderr, "Header id 0x%04x, length %d\n",
836 /* Zip64 extended information extra field. */
838 zip->uncompressed_size = archive_le64dec(p + offset);
840 zip->compressed_size = archive_le64dec(p + offset + 8);
844 /* Extended time field "UT". */
845 int flags = p[offset];
848 /* Flag bits indicate which dates are present. */
852 fprintf(stderr, "mtime: %lld -> %d\n",
853 (long long)zip->mtime,
854 archive_le32dec(p + offset));
858 zip->mtime = archive_le32dec(p + offset);
866 zip->atime = archive_le32dec(p + offset);
874 zip->ctime = archive_le32dec(p + offset);
881 /* Info-ZIP Unix Extra Field (type 2) "Ux". */
883 fprintf(stderr, "uid %d gid %d\n",
884 archive_le16dec(p + offset),
885 archive_le16dec(p + offset + 2));
888 zip->uid = archive_le16dec(p + offset);
890 zip->gid = archive_le16dec(p + offset + 2);
898 if (offset != zip->extra_length)
901 "Extra data field contents do not match reported size!");