/* Specification of ZIP file format can be found here: *https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT *ForahighleveloverviewofthestructureofaZIPfilesee *sections4.3.1-4.3.6. * *DatastructuresappearinginZIPfilesdonotcontainany *paddingandtheymightbemisaligned.Toallowustosafely *operateonpointerstosuchstructuresandtheirmembers,we *declarethetypesaspacked.
*/
#define END_OF_CD_RECORD_MAGIC 0x06054b50
/* See section 4.3.16 of the spec. */ struct end_of_cd_record { /* Magic value equal to END_OF_CD_RECORD_MAGIC */
__u32 magic;
/* Number of the file containing this structure or 0xFFFF if ZIP64 archive. *Ziparchivemightspanmultiplefiles(disks).
*/
__u16 this_disk;
/* Number of the file containing the beginning of the central directory or *0xFFFFifZIP64archive.
*/
__u16 cd_disk;
/* Number of central directory records on this disk or 0xFFFF if ZIP64 *archive.
*/
__u16 cd_records;
/* Number of central directory records on all disks or 0xFFFF if ZIP64 *archive.
*/
__u16 cd_records_total;
/* Size of the central directory record or 0xFFFFFFFF if ZIP64 archive. */
__u32 cd_size;
/* Offset of the central directory from the beginning of the archive or *0xFFFFFFFFifZIP64archive.
*/
__u32 cd_offset;
/* Length of comment data following end of central directory record. */
__u16 comment_length;
/* Up to 64k of arbitrary bytes. */ /* uint8_t comment[comment_length] */
} __attribute__((packed));
/* See section 4.3.12 of the spec. */ struct cd_file_header { /* Magic value equal to CD_FILE_HEADER_MAGIC. */
__u32 magic;
__u16 version; /* Minimum zip version needed to extract the file. */
__u16 min_version;
__u16 flags;
__u16 compression;
__u16 last_modified_time;
__u16 last_modified_date;
__u32 crc;
__u32 compressed_size;
__u32 uncompressed_size;
__u16 file_name_length;
__u16 extra_field_length;
__u16 file_comment_length; /* Number of the disk where the file starts or 0xFFFF if ZIP64 archive. */
__u16 disk;
__u16 internal_attributes;
__u32 external_attributes; /* Offset from the start of the disk containing the local file header to the *startofthelocalfileheader.
*/
__u32 offset;
} __attribute__((packed));
#define LOCAL_FILE_HEADER_MAGIC 0x04034b50
/* See section 4.3.7 of the spec. */ struct local_file_header { /* Magic value equal to LOCAL_FILE_HEADER_MAGIC. */
__u32 magic; /* Minimum zip version needed to extract the file. */
__u16 min_version;
__u16 flags;
__u16 compression;
__u16 last_modified_time;
__u16 last_modified_date;
__u32 crc;
__u32 compressed_size;
__u32 uncompressed_size;
__u16 file_name_length;
__u16 extra_field_length;
} __attribute__((packed));
cd_records = eocd->cd_records; if (eocd->this_disk != 0 || eocd->cd_disk != 0 || eocd->cd_records_total != cd_records) /* This is a valid eocd, but we only support single-file non-ZIP64 archives. */ return -ENOTSUP;
if (archive->size <= sizeof(struct end_of_cd_record)) return -EINVAL;
/* Because the end of central directory ends with a variable length array of *upto0xFFFFbyteswecan'tknowexactlywhereitstartsandneedto *searchforitattheendofthefile,scanningthe(limit,offset]range.
*/
offset = archive->size - sizeof(struct end_of_cd_record);
limit = (int64_t)offset - (1 << 16);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.