version 1.1.1.1, 2012/02/21 23:47:59
|
version 1.1.1.2, 2013/07/22 01:31:59
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| ZIP archive support for Phar | |
| ZIP archive support for Phar | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 2007-2012 The PHP Group | | | Copyright (c) 2007-2013 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 603 foundit:
|
Line 603 foundit:
|
|
|
php_stream_filter_append(&fp->readfilters, filter); |
php_stream_filter_append(&fp->readfilters, filter); |
|
|
#if PHP_MAJOR_VERSION >= 6 |
|
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
|
#else |
|
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
#endif |
|
pefree(entry.filename, entry.is_persistent); |
pefree(entry.filename, entry.is_persistent); |
#if PHP_VERSION_ID < 50207 |
#if PHP_VERSION_ID < 50207 |
PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); |
PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); |
Line 628 foundit:
|
Line 624 foundit:
|
|
|
php_stream_filter_append(&fp->readfilters, filter); |
php_stream_filter_append(&fp->readfilters, filter); |
|
|
#if PHP_MAJOR_VERSION >= 6 |
|
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
|
#else |
|
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
#endif |
|
pefree(entry.filename, entry.is_persistent); |
pefree(entry.filename, entry.is_persistent); |
#if PHP_VERSION_ID < 50207 |
#if PHP_VERSION_ID < 50207 |
PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); |
PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); |
Line 643 foundit:
|
Line 635 foundit:
|
php_stream_filter_flush(filter, 1); |
php_stream_filter_flush(filter, 1); |
php_stream_filter_remove(filter, 1 TSRMLS_CC); |
php_stream_filter_remove(filter, 1 TSRMLS_CC); |
} else { |
} else { |
#if PHP_MAJOR_VERSION >= 6 |
|
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
|
#else |
|
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { |
#endif |
|
pefree(entry.filename, entry.is_persistent); |
pefree(entry.filename, entry.is_persistent); |
PHAR_ZIP_FAIL("unable to read in alias, truncated"); |
PHAR_ZIP_FAIL("unable to read in alias, truncated"); |
} |
} |
Line 949 is_compressed:
|
Line 937 is_compressed:
|
PHAR_SET_32(local.uncompsize, entry->uncompressed_filesize); |
PHAR_SET_32(local.uncompsize, entry->uncompressed_filesize); |
PHAR_SET_32(central.compsize, entry->compressed_filesize); |
PHAR_SET_32(central.compsize, entry->compressed_filesize); |
PHAR_SET_32(local.compsize, entry->compressed_filesize); |
PHAR_SET_32(local.compsize, entry->compressed_filesize); |
| if (p->old) { |
if (-1 == php_stream_seek(p->old, entry->offset_abs, SEEK_SET)) { | if (-1 == php_stream_seek(p->old, entry->offset_abs, SEEK_SET)) { |
spprintf(p->error, 0, "unable to seek to start of file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname); | spprintf(p->error, 0, "unable to seek to start of file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname); |
return ZEND_HASH_APPLY_STOP; | return ZEND_HASH_APPLY_STOP; |
| } |
} |
} |
} |
} |
not_compressed: |
not_compressed: |
Line 1107 static int phar_zip_applysignature(phar_archive_data *
|
Line 1096 static int phar_zip_applysignature(phar_archive_data *
|
off_t tell, st; |
off_t tell, st; |
|
|
newfile = php_stream_fopen_tmpfile(); |
newfile = php_stream_fopen_tmpfile(); |
|
if (newfile == NULL) { |
|
spprintf(pass->error, 0, "phar error: unable to create temporary file for the signature file"); |
|
return FAILURE; |
|
} |
st = tell = php_stream_tell(pass->filefp); |
st = tell = php_stream_tell(pass->filefp); |
/* copy the local files, central directory, and the zip comment to generate the hash */ |
/* copy the local files, central directory, and the zip comment to generate the hash */ |
php_stream_seek(pass->filefp, 0, SEEK_SET); |
php_stream_seek(pass->filefp, 0, SEEK_SET); |
Line 1134 static int phar_zip_applysignature(phar_archive_data *
|
Line 1127 static int phar_zip_applysignature(phar_archive_data *
|
entry.fp = php_stream_fopen_tmpfile(); |
entry.fp = php_stream_fopen_tmpfile(); |
entry.fp_type = PHAR_MOD; |
entry.fp_type = PHAR_MOD; |
entry.is_modified = 1; |
entry.is_modified = 1; |
|
if (entry.fp == NULL) { |
|
spprintf(pass->error, 0, "phar error: unable to create temporary file for signature"); |
|
return FAILURE; |
|
} |
|
|
PHAR_SET_32(sigbuf, phar->sig_flags); |
PHAR_SET_32(sigbuf, phar->sig_flags); |
PHAR_SET_32(sigbuf + 4, signature_length); |
PHAR_SET_32(sigbuf + 4, signature_length); |
Line 1204 int phar_zip_flush(phar_archive_data *phar, char *user
|
Line 1201 int phar_zip_flush(phar_archive_data *phar, char *user
|
/* set alias */ |
/* set alias */ |
if (!phar->is_temporary_alias && phar->alias_len) { |
if (!phar->is_temporary_alias && phar->alias_len) { |
entry.fp = php_stream_fopen_tmpfile(); |
entry.fp = php_stream_fopen_tmpfile(); |
| if (entry.fp == NULL) { |
| spprintf(error, 0, "phar error: unable to create temporary file"); |
| return EOF; |
| } |
if (phar->alias_len != (int)php_stream_write(entry.fp, phar->alias, phar->alias_len)) { |
if (phar->alias_len != (int)php_stream_write(entry.fp, phar->alias, phar->alias_len)) { |
if (error) { |
if (error) { |
spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname); |
spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname); |
Line 1252 int phar_zip_flush(phar_archive_data *phar, char *user
|
Line 1252 int phar_zip_flush(phar_archive_data *phar, char *user
|
|
|
user_stub = 0; |
user_stub = 0; |
|
|
#if PHP_MAJOR_VERSION >= 6 |
|
if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) { |
|
#else |
|
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) { |
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) { |
#endif |
|
if (error) { |
if (error) { |
spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname); |
spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname); |
} |
} |
Line 1283 int phar_zip_flush(phar_archive_data *phar, char *user
|
Line 1279 int phar_zip_flush(phar_archive_data *phar, char *user
|
|
|
len = pos - user_stub + 18; |
len = pos - user_stub + 18; |
entry.fp = php_stream_fopen_tmpfile(); |
entry.fp = php_stream_fopen_tmpfile(); |
|
if (entry.fp == NULL) { |
|
spprintf(error, 0, "phar error: unable to create temporary file"); |
|
return EOF; |
|
} |
entry.uncompressed_filesize = len + 5; |
entry.uncompressed_filesize = len + 5; |
|
|
if ((size_t)len != php_stream_write(entry.fp, user_stub, len) |
if ((size_t)len != php_stream_write(entry.fp, user_stub, len) |
Line 1316 int phar_zip_flush(phar_archive_data *phar, char *user
|
Line 1316 int phar_zip_flush(phar_archive_data *phar, char *user
|
} else { |
} else { |
/* Either this is a brand new phar (add the stub), or the default stub is required (overwrite the stub) */ |
/* Either this is a brand new phar (add the stub), or the default stub is required (overwrite the stub) */ |
entry.fp = php_stream_fopen_tmpfile(); |
entry.fp = php_stream_fopen_tmpfile(); |
| if (entry.fp == NULL) { |
| spprintf(error, 0, "phar error: unable to create temporary file"); |
| return EOF; |
| } |
if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) { |
if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) { |
php_stream_close(entry.fp); |
php_stream_close(entry.fp); |
if (error) { |
if (error) { |