pajoye Thu, 04 Feb 2010 10:09:25 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=294522
Log:
- update lib to 0.9.3, fix leaks and test
Changed paths:
_U php/php-src/branches/PHP_5_3_2/
_U php/php-src/branches/PHP_5_3_2/ext/tidy/tests/
U php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_close.c
U php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_dirent.c
U php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_file_get_offset.c
U php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_fread.c
U php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_open.c
U php/php-src/branches/PHP_5_3_2/ext/zip/lib/zipint.h
U php/php-src/branches/PHP_5_3_2/ext/zip/tests/bug47667.phpt
_U
php/php-src/branches/PHP_5_3_2/tests/security/open_basedir_parse_ini_file.phpt
Property changes on: php/php-src/branches/PHP_5_3_2
___________________________________________________________________
Modified: svn:mergeinfo
- /php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292716,292719,292762,292765,292771,292777,292823,293051,293075,293114,293126,293131,293144,293146,293152,293176,293180,293216,293235,293253,293268,293341,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293762,293768,293804,293862,293897,293901-293902,293906,293965,293974,293985,293998,294040,294053,294089,294094,294100,294102,294104,294267,294269,294272,294278,294285,294303,294307,294310,294312,294418
/php/php-src/trunk:284726
+ /php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292716,292719,292762,292765,292771,292777,292823,293051,293075,293114,293126,293131,293144,293146,293152,293176,293180,293216,293235,293253,293268,293341,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293762,293768,293804,293862,293897,293901-293902,293906,293965,293974,293985,293998,294040,294053,294089,294094,294100,294102,294104,294267,294269,294272,294278,294285,294303,294307,294310,294312,294320-294323,294418
/php/php-src/trunk:284726
Property changes on: php/php-src/branches/PHP_5_3_2/ext/tidy/tests
___________________________________________________________________
Modified: svn:mergeinfo
- /php/php-src/branches/PHP_5_3/ext/tidy/tests:292562,292566,292571,292574,292635,292716,292719,292765,293146,293152,293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293762,293768,293804,293862,293897,293901-293902,293906,293965,293985,293998,294040,294053,294089,294094,294100,294102,294104,294267,294269,294272,294278,294285,294303,294307,294310,294312,294418
/php/php-src/trunk/ext/tidy/tests:284726,287798-287941
+ /php/php-src/branches/PHP_5_3/ext/tidy/tests:292562,292566,292571,292574,292635,292716,292719,292765,293146,293152,293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293762,293768,293804,293862,293897,293901-293902,293906,293965,293985,293998,294040,294053,294089,294094,294100,294102,294104,294267,294269,294272,294278,294285,294303,294307,294310,294312,294320-294323,294418
/php/php-src/trunk/ext/tidy/tests:284726,287798-287941
Modified: php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_close.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_close.c 2010-02-04 10:08:07 UTC (rev 294521)
+++ php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_close.c 2010-02-04 10:09:25 UTC (rev 294522)
@@ -135,6 +135,7 @@
if ((temp=_zip_create_temp_output(za, &out)) == NULL) {
_zip_cdir_free(cd);
+ free(filelist);
return -1;
}
@@ -192,7 +193,8 @@
error = 1;
break;
}
- if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0) {
+ if (_zip_dirent_read(&de, za->zp, NULL, NULL, 1,
+ &za->error) != 0) {
error = 1;
break;
}
@@ -264,6 +266,8 @@
_zip_dirent_finalize(&de);
}
+ free(filelist);
+
if (!error) {
if (write_cdir(za, cd, out) < 0)
error = 1;
@@ -306,6 +310,8 @@
mask = umask(0);
umask(mask);
chmod(za->zn, 0666&~mask);
+ if (za->ch_comment)
+ free(za->ch_comment);
_zip_free(za);
free(temp);
@@ -443,6 +449,7 @@
zstr.next_out = (Bytef *)b2;
zstr.avail_out = sizeof(b2);
+ zstr.next_in = NULL;
zstr.avail_in = 0;
flush = 0;
Modified: php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_dirent.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_dirent.c 2010-02-04 10:08:07 UTC (rev 294521)
+++ php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_dirent.c 2010-02-04 10:09:25 UTC (rev 294522)
@@ -68,6 +68,30 @@
+int
+_zip_cdir_grow(struct zip_cdir *cd, int nentry, struct zip_error *error)
+{
+ struct zip_dirent *entry;
+
+ if (nentry < cd->nentry) {
+ _zip_error_set(error, ZIP_ER_INTERNAL, 0);
+ return -1;
+ }
+
+ if ((entry=((struct zip_dirent *)
+ realloc(cd->entry, sizeof(*(cd->entry))*nentry))) == NULL) {
+ _zip_error_set(error, ZIP_ER_MEMORY, 0);
+ return -1;
+ }
+
+ cd->nentry = nentry;
+ cd->entry = entry;
+
+ return 0;
+}
+
+
+
struct zip_cdir *
_zip_cdir_new(int nentry, struct zip_error *error)
{
@@ -173,19 +197,23 @@
Fills the zip directory entry zde.
If bufp is non-NULL, data is taken from there and bufp is advanced
- by the amount of data used; no more than left bytes are used.
- Otherwise data is read from fp as needed.
+ by the amount of data used; otherwise data is read from fp as needed.
+
+ if leftp is non-NULL, no more bytes than specified by it are used,
+ and *leftp is reduced by the number of bytes used.
- If localp != 0, it reads a local header instead of a central
+ If local != 0, it reads a local header instead of a central
directory entry.
Returns 0 if successful. On error, error is filled in and -1 is
returned.
+
+ XXX: leftp and file position undefined on error.
*/
int
_zip_dirent_read(struct zip_dirent *zde, FILE *fp,
- unsigned char **bufp, unsigned int left, int localp,
+ unsigned char **bufp, unsigned int *leftp, int local,
struct zip_error *error)
{
unsigned char buf[CDENTRYSIZE];
@@ -193,18 +221,19 @@
unsigned short dostime, dosdate;
unsigned int size;
- if (localp)
+ if (local)
size = LENTRYSIZE;
else
size = CDENTRYSIZE;
-
+
+ if (leftp && (*leftp < size)) {
+ _zip_error_set(error, ZIP_ER_NOZIP, 0);
+ return -1;
+ }
+
if (bufp) {
/* use data from buffer */
cur = *bufp;
- if (left < size) {
- _zip_error_set(error, ZIP_ER_NOZIP, 0);
- return -1;
- }
}
else {
/* read entry from disk */
@@ -212,11 +241,10 @@
_zip_error_set(error, ZIP_ER_READ, errno);
return -1;
}
- left = size;
cur = buf;
}
- if (memcmp(cur, (localp ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) {
+ if (memcmp(cur, (local ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) {
_zip_error_set(error, ZIP_ER_NOZIP, 0);
return -1;
}
@@ -225,7 +253,7 @@
/* convert buffercontents to zip_dirent */
- if (!localp)
+ if (!local)
zde->version_madeby = _zip_read2(&cur);
else
zde->version_madeby = 0;
@@ -245,7 +273,7 @@
zde->filename_len = _zip_read2(&cur);
zde->extrafield_len = _zip_read2(&cur);
- if (localp) {
+ if (local) {
zde->comment_len = 0;
zde->disk_number = 0;
zde->int_attrib = 0;
@@ -263,13 +291,14 @@
zde->extrafield = NULL;
zde->comment = NULL;
+ size += zde->filename_len+zde->extrafield_len+zde->comment_len;
+
+ if (leftp && (*leftp < size)) {
+ _zip_error_set(error, ZIP_ER_NOZIP, 0);
+ return -1;
+ }
+
if (bufp) {
- if (left < CDENTRYSIZE + (zde->filename_len+zde->extrafield_len
- +zde->comment_len)) {
- _zip_error_set(error, ZIP_ER_NOZIP, 0);
- return -1;
- }
-
if (zde->filename_len) {
zde->filename = _zip_readstr(&cur, zde->filename_len, 1, error);
if (!zde->filename)
@@ -312,6 +341,8 @@
if (bufp)
*bufp = cur;
+ if (leftp)
+ *leftp -= size;
return 0;
}
@@ -442,23 +473,22 @@
static time_t
_zip_d2u_time(int dtime, int ddate)
{
- struct tm *tm;
- time_t now;
+ struct tm tm;
- now = time(NULL);
- tm = localtime(&now);
+ memset(&tm, sizeof(tm), 0);
+
/* let mktime decide if DST is in effect */
- tm->tm_isdst = -1;
+ tm.tm_isdst = -1;
- tm->tm_year = ((ddate>>9)&127) + 1980 - 1900;
- tm->tm_mon = ((ddate>>5)&15) - 1;
- tm->tm_mday = ddate&31;
+ tm.tm_year = ((ddate>>9)&127) + 1980 - 1900;
+ tm.tm_mon = ((ddate>>5)&15) - 1;
+ tm.tm_mday = ddate&31;
- tm->tm_hour = (dtime>>11)&31;
- tm->tm_min = (dtime>>5)&63;
- tm->tm_sec = (dtime<<1)&62;
+ tm.tm_hour = (dtime>>11)&31;
+ tm.tm_min = (dtime>>5)&63;
+ tm.tm_sec = (dtime<<1)&62;
- return mktime(tm);
+ return mktime(&tm);
}
Modified: php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_file_get_offset.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_file_get_offset.c 2010-02-04 10:08:07 UTC (rev 294521)
+++ php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_file_get_offset.c 2010-02-04 10:09:25 UTC (rev 294522)
@@ -63,7 +63,7 @@
return 0;
}
- if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0)
+ if (_zip_dirent_read(&de, za->zp, NULL, NULL, 1, &za->error) != 0)
return 0;
offset += LENTRYSIZE + de.filename_len + de.extrafield_len;
Modified: php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_fread.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_fread.c 2010-02-04 10:08:07 UTC (rev 294521)
+++ php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_fread.c 2010-02-04 10:09:25 UTC (rev 294522)
@@ -63,7 +63,7 @@
}
return 0;
}
-
+
if ((zf->flags & ZIP_ZF_DECOMP) == 0) {
ret = _zip_file_fillbuf(outbuf, toread, zf);
if (ret > 0) {
@@ -84,25 +84,22 @@
switch (ret) {
case Z_STREAM_END:
- zf->flags |= ZIP_ZF_EOF;
+ if (zf->zstr->total_out == out_before) {
+ if (zf->crc != zf->crc_orig) {
+ _zip_error_set(&zf->error, ZIP_ER_CRC, 0);
+ return -1;
+ }
+ else
+ return 0;
+ }
- case Z_OK:
+ /* fallthrough */
- /* all ok */
- /* Z_STREAM_END probably won't happen, since we didn't
- have a header */
+ case Z_OK:
len = zf->zstr->total_out - out_before;
if (len >= zf->bytes_left || len >= toread) {
- if (zf->flags & ZIP_ZF_CRC) {
- zf->crc = crc32(zf->crc, (Bytef *)outbuf, len);
- if (zf->flags & ZIP_ZF_EOF == 1) {
- if (zf->crc != zf->crc_orig) {
- _zip_error_set(&zf->error, ZIP_ER_CRC, 0);
- return -1;
- }
-
- }
- }
+ if (zf->flags & ZIP_ZF_CRC)
+ zf->crc = crc32(zf->crc, (Bytef *)outbuf, len);
zf->bytes_left -= len;
return len;
}
Modified: php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_open.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_open.c 2010-02-04 10:08:07 UTC (rev 294521)
+++ php/php-src/branches/PHP_5_3_2/ext/zip/lib/zip_open.c 2010-02-04 10:09:25 UTC (rev 294522)
@@ -162,6 +162,7 @@
struct zip_cdir *cd;
unsigned char *cdp, **bufp;
int i, comlen, nentry;
+ unsigned int left;
comlen = buf + buflen - eocd - EOCDLEN;
if (comlen < 0) {
@@ -215,7 +216,6 @@
}
}
- cdp = eocd;
if (cd->size < (unsigned int)(eocd-buf)) {
/* if buffer already read in, use it */
cdp = eocd - cd->size;
@@ -239,14 +239,23 @@
}
}
- for (i=0; i<cd->nentry; i++) {
- if ((_zip_dirent_read(cd->entry+i, fp, bufp, eocd-cdp, 0,
- error)) < 0) {
+ left = cd->size;
+ i=0;
+ do {
+ if (i == cd->nentry && left > 0) {
+ /* Infozip extension for more than 64k entries:
+ nentries wraps around, size indicates correct EOCD */
+ _zip_cdir_grow(cd, cd->nentry+0x10000, error);
+ }
+
+ if ((_zip_dirent_read(cd->entry+i, fp, bufp, &left, 0, error)) < 0) {
cd->nentry = i;
_zip_cdir_free(cd);
return NULL;
}
- }
+ i++;
+
+ } while (i<cd->nentry);
return cd;
}
@@ -295,7 +304,7 @@
return -1;
}
- if (_zip_dirent_read(&temp, fp, NULL, 0, 1, error) == -1)
+ if (_zip_dirent_read(&temp, fp, NULL, NULL, 1, error) == -1)
return -1;
if (_zip_headercomp(cd->entry+i, 0, &temp, 1) != 0) {
Modified: php/php-src/branches/PHP_5_3_2/ext/zip/lib/zipint.h
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/zip/lib/zipint.h 2010-02-04 10:08:07 UTC (rev 294521)
+++ php/php-src/branches/PHP_5_3_2/ext/zip/lib/zipint.h 2010-02-04 10:09:25 UTC (rev 294522)
@@ -213,13 +213,14 @@
int _zip_cdir_compute_crc(struct zip *, uLong *);
void _zip_cdir_free(struct zip_cdir *);
+int _zip_cdir_grow(struct zip_cdir *, int, struct zip_error *);
struct zip_cdir *_zip_cdir_new(int, struct zip_error *);
int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
void _zip_dirent_finalize(struct zip_dirent *);
void _zip_dirent_init(struct zip_dirent *);
-int _zip_dirent_read(struct zip_dirent *, FILE *,
- unsigned char **, unsigned int, int, struct zip_error *);
+int _zip_dirent_read(struct zip_dirent *, FILE *, unsigned char **,
+ unsigned int *, int, struct zip_error *);
void _zip_dirent_torrent_normalize(struct zip_dirent *);
int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
Modified: php/php-src/branches/PHP_5_3_2/ext/zip/tests/bug47667.phpt
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/zip/tests/bug47667.phpt 2010-02-04 10:08:07 UTC (rev 294521)
+++ php/php-src/branches/PHP_5_3_2/ext/zip/tests/bug47667.phpt 2010-02-04 10:09:25 UTC (rev 294522)
@@ -33,6 +33,7 @@
}
echo "files: " , $zip->numFiles;
+$zip->close();
unlink($filename);
Property changes on: php/php-src/branches/PHP_5_3_2/tests/security/open_basedir_parse_ini_file.phpt
___________________________________________________________________
Modified: svn:mergeinfo
- /php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:292562,292566,292571,292574,292716,293146,293152,293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293762,293768,293804,293862,293897,293901-293902,293906,293965,293985,293998,294040,294053,294089,294094,294100,294102,294104,294267,294269,294272,294278,294285,294303,294307,294310,294312,294418
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:265951
+ /php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:292562,292566,292571,292574,292716,293146,293152,293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293762,293768,293804,293862,293897,293901-293902,293906,293965,293985,293998,294040,294053,294089,294094,294100,294102,294104,294267,294269,294272,294278,294285,294303,294307,294310,294312,294320-294323,294418
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:265951
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php