--- /dev/null
+<?php
+include dirname(__FILE__) . '/corrupt_zipmaker.php.inc';
+$a = new corrupt_zipmaker;
+$a->addFile('hi', null, 'hii');
+$a->addFile('hi2', null, 'hii2');
+$a->writeZip(dirname(__FILE__) . '/count1.zip', 'count1');
+$a->writeZip(dirname(__FILE__) . '/count2.zip', 'count2');
+?>
size = sizeof(locator) + 65536;
if (FAILURE == php_stream_seek(fp, -size, SEEK_END)) {
php_stream_close(fp);
+ if (error) {
+ spprintf(error, 4096, "phar error: unable to search for end of central directory in zip-based phar \"%s\"", fname);
+ }
return FAILURE;
}
} else {
}
if (!(read = php_stream_read(fp, buf, size))) {
php_stream_close(fp);
+ if (error) {
+ spprintf(error, 4096, "phar error: unable to read in data to search for end of central directory in zip-based phar \"%s\"", fname);
+ }
return FAILURE;
}
while ((p=(char *) memchr(p + 1, 'P', (size_t)(buf - (p+1) + sizeof(locator) + 65536 - 4 + 1))) != NULL) {
}
}
php_stream_close(fp);
+ if (error) {
+ spprintf(error, 4096, "phar error: end of central directory not found in zip-based phar \"%s\"", fname);
+ }
return FAILURE;
foundit:
if (locator.centraldisk != 0 || locator.disknumber != 0) {
/* split archives not handled */
php_stream_close(fp);
+ if (error) {
+ spprintf(error, 4096, "phar error: split archives spanning multiple zips cannot be processed in zip-based phar \"%s\"", fname);
+ }
+ return FAILURE;
+ }
+ if (locator.counthere != locator.count) {
+ if (error) {
+ spprintf(error, 4096, "phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar \"%s\"", fname);
+ }
+ php_stream_close(fp);
return FAILURE;
}
mydata = ecalloc(sizeof(phar_archive_data), 1);