diff options
author | Stanislav Malyshev <stas@php.net> | 2013-07-23 21:44:54 -0700 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2013-07-23 21:45:35 -0700 |
commit | b8c8a04a85baf4bee2e3ce5891cd7d5d97cea303 (patch) | |
tree | b6e6d2bcd26ea33ef88c2e3da38c91d087960b8f /ext/phar/phar.c | |
parent | f9000fde98195844b4d1c1d6209f9796da3ebee8 (diff) | |
parent | 96a53f6715ac563fa70f2db231478ecd0d313ff0 (diff) | |
download | php-git-b8c8a04a85baf4bee2e3ce5891cd7d5d97cea303.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
fix bug #65028 Phar::buildFromDirectory creates corrupt archives for some specific contents
Diffstat (limited to 'ext/phar/phar.c')
-rw-r--r-- | ext/phar/phar.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 638c1ef83a..ec8e5fbde7 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -2579,6 +2579,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, php_serialize_data_t metadata_hash; smart_str main_metadata_str = {0}; int free_user_stub, free_fp = 1, free_ufp = 1; + int manifest_hack = 0; if (phar->is_persistent) { if (error) { @@ -2930,6 +2931,12 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, manifest_len = offset + phar->alias_len + sizeof(manifest) + main_metadata_str.len; phar_set_32(manifest, manifest_len); + /* Hack - see bug #65028, add padding byte to the end of the manifest */ + if(manifest[0] == '\r' || manifest[0] == '\n') { + manifest_len++; + phar_set_32(manifest, manifest_len); + manifest_hack = 1; + } phar_set_32(manifest+4, new_manifest_count); if (has_dirs) { *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF); @@ -3054,6 +3061,22 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, return EOF; } } + /* Hack - see bug #65028, add padding byte to the end of the manifest */ + if(manifest_hack) { + if(1 != php_stream_write(newfile, manifest, 1)) { + if (closeoldfile) { + php_stream_close(oldfile); + } + + php_stream_close(newfile); + + if (error) { + spprintf(error, 0, "unable to write manifest padding byte"); + } + + return EOF; + } + } /* now copy the actual file data to the new phar */ offset = php_stream_tell(newfile); |