From: Greg Beaver Date: Wed, 16 Apr 2008 04:34:25 +0000 (+0000) Subject: fix end of directory locator detection code, add failing test for large zips X-Git-Tag: RELEASE_2_0_0b1~354 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e584728e5763f3791262626b1f5b8e5b4eceef6;p=php fix end of directory locator detection code, add failing test for large zips --- diff --git a/ext/phar/tests/zip/largezip.phpt b/ext/phar/tests/zip/largezip.phpt new file mode 100644 index 0000000000..93cbaca256 --- /dev/null +++ b/ext/phar/tests/zip/largezip.phpt @@ -0,0 +1,29 @@ +--TEST-- +Phar: large zip file (zip edge cases) +--SKIPIF-- + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- + +===DONE=== +--CLEAN-- + + +--EXPECT-- +int(100000) +===DONE=== diff --git a/ext/phar/zip.c b/ext/phar/zip.c index c77273dafe..9e0ddce9e7 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -168,6 +168,9 @@ int phar_open_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, i php_stream_close(fp); return FAILURE; } + if (*p == 'P' && !memcmp(p + 1, "K\5\6", 3)) { + goto copybuf; + } while ((p=(char *) memchr(p + 1, 'P', (size_t)(buf - (p+1) + 8192 - 4 + 1))) != NULL) { if (!memcmp(p + 1, "K\5\6", 3)) { if (p - buf < sizeof(locator)) { @@ -178,6 +181,7 @@ int phar_open_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, i return FAILURE; } } else { +copybuf: memcpy((void *)&locator, (void *) p, sizeof(locator)); } goto foundit;