Skip to content

Commit

Permalink
Fixed compat layer structures layout and types. #749
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed Dec 17, 2023
1 parent 6c5f265 commit bacf512
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 39 deletions.
4 changes: 2 additions & 2 deletions mz_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo
dos_date = mz_zip_tm_to_dosdate(&zipfi->tmz_date);

file_info.modified_date = mz_zip_dosdate_to_time_t(dos_date);
file_info.external_fa = zipfi->external_fa;
file_info.internal_fa = zipfi->internal_fa;
file_info.external_fa = (uint32_t)zipfi->external_fa;
file_info.internal_fa = (uint16_t)zipfi->internal_fa;
}

if (!filename)
Expand Down
76 changes: 39 additions & 37 deletions mz_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ typedef struct tm tm_unz;
typedef struct tm tm_zip;

typedef struct {
uint32_t mz_dos_date;
struct tm tmz_date;
uint16_t internal_fa; /* internal file attributes 2 bytes */
uint32_t external_fa; /* external file attributes 4 bytes */
struct tm tmz_date; /* date in understandable format */
unsigned long mz_dos_date; /* if dos_date == 0, tmz_date is used */
unsigned long internal_fa; /* internal file attributes 2 bytes */
unsigned long external_fa; /* external file attributes 4 bytes */
} zip_fileinfo;

typedef const char *zipcharpc;
Expand Down Expand Up @@ -252,56 +252,58 @@ typedef void *unzFile;

typedef struct unz_global_info64_s {
uint64_t number_entry; /* total number of entries in the central dir on this disk */
unsigned long size_comment; /* size of the global comment of the zipfile */
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */
uint16_t size_comment; /* size of the global comment of the zipfile */
} unz_global_info64;

typedef struct unz_global_info_s {
uint32_t number_entry; /* total number of entries in the central dir on this disk */
unsigned long number_entry; /* total number of entries in the central dir on this disk */
unsigned long size_comment; /* size of the global comment of the zipfile */
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */
uint16_t size_comment; /* size of the global comment of the zipfile */
} unz_global_info;

typedef struct unz_file_info64_s {
uint16_t version; /* version made by 2 bytes */
uint16_t version_needed; /* version needed to extract 2 bytes */
uint16_t flag; /* general purpose bit flag 2 bytes */
uint16_t compression_method; /* compression method 2 bytes */
uint32_t mz_dos_date; /* last mod file date in Dos fmt 4 bytes */
struct tm tmu_date;
uint32_t crc; /* crc-32 4 bytes */
uint64_t compressed_size; /* compressed size 8 bytes */
uint64_t uncompressed_size; /* uncompressed size 8 bytes */
uint16_t size_filename; /* filename length 2 bytes */
uint16_t size_file_extra; /* extra field length 2 bytes */
uint16_t size_file_comment; /* file comment length 2 bytes */
unsigned long version; /* version made by 2 bytes */
unsigned long version_needed; /* version needed to extract 2 bytes */
unsigned long flag; /* general purpose bit flag 2 bytes */
unsigned long compression_method; /* compression method 2 bytes */
unsigned long mz_dos_date; /* last mod file date in Dos fmt 4 bytes */
unsigned long crc; /* crc-32 4 bytes */
uint64_t compressed_size; /* compressed size 8 bytes */
uint64_t uncompressed_size; /* uncompressed size 8 bytes */
unsigned long size_filename; /* filename length 2 bytes */
unsigned long size_file_extra; /* extra field length 2 bytes */
unsigned long size_file_comment; /* file comment length 2 bytes */

unsigned long disk_num_start; /* disk number start 4 bytes */
unsigned long internal_fa; /* internal file attributes 2 bytes */
unsigned long external_fa; /* external file attributes 4 bytes */

uint32_t disk_num_start; /* disk number start 4 bytes */
uint16_t internal_fa; /* internal file attributes 2 bytes */
uint32_t external_fa; /* external file attributes 4 bytes */
struct tm tmu_date;

uint64_t disk_offset;

uint16_t size_file_extra_internal;
} unz_file_info64;

typedef struct unz_file_info_s {
uint16_t version; /* version made by 2 bytes */
uint16_t version_needed; /* version needed to extract 2 bytes */
uint16_t flag; /* general purpose bit flag 2 bytes */
uint16_t compression_method; /* compression method 2 bytes */
uint32_t mz_dos_date; /* last mod file date in Dos fmt 4 bytes */
unsigned long version; /* version made by 2 bytes */
unsigned long version_needed; /* version needed to extract 2 bytes */
unsigned long flag; /* general purpose bit flag 2 bytes */
unsigned long compression_method; /* compression method 2 bytes */
unsigned long mz_dos_date; /* last mod file date in Dos fmt 4 bytes */
unsigned long crc; /* crc-32 4 bytes */
unsigned long compressed_size; /* compressed size 4 bytes */
unsigned long uncompressed_size; /* uncompressed size 4 bytes */
unsigned long size_filename; /* filename length 2 bytes */
unsigned long size_file_extra; /* extra field length 2 bytes */
unsigned long size_file_comment; /* file comment length 2 bytes */

unsigned long disk_num_start; /* disk number start 2 bytes */
unsigned long internal_fa; /* internal file attributes 2 bytes */
unsigned long external_fa; /* external file attributes 4 bytes */

struct tm tmu_date;
uint32_t crc; /* crc-32 4 bytes */
uint32_t compressed_size; /* compressed size 4 bytes */
uint32_t uncompressed_size; /* uncompressed size 4 bytes */
uint16_t size_filename; /* filename length 2 bytes */
uint16_t size_file_extra; /* extra field length 2 bytes */
uint16_t size_file_comment; /* file comment length 2 bytes */

uint16_t disk_num_start; /* disk number start 2 bytes */
uint16_t internal_fa; /* internal file attributes 2 bytes */
uint32_t external_fa; /* external file attributes 4 bytes */

uint64_t disk_offset;
} unz_file_info;
Expand Down

0 comments on commit bacf512

Please sign in to comment.