--- embedaddon/php/ext/zip/lib/zip_dirent.c 2012/02/21 23:48:05 1.1.1.1 +++ embedaddon/php/ext/zip/lib/zip_dirent.c 2013/07/22 01:32:11 1.1.1.2 @@ -45,7 +45,6 @@ static time_t _zip_d2u_time(int, int); static char *_zip_readfpstr(FILE *, unsigned int, int, struct zip_error *); static char *_zip_readstr(unsigned char **, int, int, struct zip_error *); -static void _zip_u2d_time(time_t, unsigned short *, unsigned short *); static void _zip_write2(unsigned short, FILE *); static void _zip_write4(unsigned int, FILE *); @@ -158,11 +157,17 @@ _zip_cdir_write(struct zip_cdir *cd, FILE *fp, struct void _zip_dirent_finalize(struct zip_dirent *zde) { - free(zde->filename); + if (zde->filename_len > 0) { + free(zde->filename); + } zde->filename = NULL; - free(zde->extrafield); + if (zde->extrafield_len > 0) { + free(zde->extrafield); + } zde->extrafield = NULL; - free(zde->comment); + if (zde->comment_len > 0) { + free(zde->comment); + } zde->comment = NULL; } @@ -213,13 +218,13 @@ _zip_dirent_init(struct zip_dirent *de) int _zip_dirent_read(struct zip_dirent *zde, FILE *fp, - unsigned char **bufp, unsigned int *leftp, int local, + unsigned char **bufp, zip_uint32_t *leftp, int local, struct zip_error *error) { unsigned char buf[CDENTRYSIZE]; unsigned char *cur; unsigned short dostime, dosdate; - unsigned int size; + zip_uint32_t size; if (local) size = LENTRYSIZE; @@ -473,8 +478,10 @@ _zip_dirent_write(struct zip_dirent *zde, FILE *fp, in static time_t _zip_d2u_time(int dtime, int ddate) { - struct tm tm = {0}; + struct tm tm; + memset(&tm, 0, sizeof(tm)); + /* let mktime decide if DST is in effect */ tm.tm_isdst = -1; @@ -598,7 +605,7 @@ _zip_write4(unsigned int i, FILE *fp) -static void +void _zip_u2d_time(time_t time, unsigned short *dtime, unsigned short *ddate) { struct tm *tm;