--- embedaddon/php/ext/phar/phar.c 2013/07/22 01:31:59 1.1.1.3 +++ embedaddon/php/ext/phar/phar.c 2013/10/14 08:02:28 1.1.1.4 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar.c,v 1.1.1.3 2013/07/22 01:31:59 misho Exp $ */ +/* $Id: phar.c,v 1.1.1.4 2013/10/14 08:02:28 misho Exp $ */ #define PHAR_MAIN 1 #include "phar_internal.h" @@ -2579,6 +2579,7 @@ int phar_flush(phar_archive_data *phar, char *user_stu 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_stu 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,7 +3061,23 @@ int phar_flush(phar_archive_data *phar, char *user_stu 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); for (zend_hash_internal_pointer_reset(&phar->manifest); @@ -3664,7 +3687,7 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */ php_info_print_table_header(2, "Phar: PHP Archive support", "enabled"); php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION); php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION); - php_info_print_table_row(2, "SVN revision", "$Id: phar.c,v 1.1.1.3 2013/07/22 01:31:59 misho Exp $"); + php_info_print_table_row(2, "SVN revision", "$Id: phar.c,v 1.1.1.4 2013/10/14 08:02:28 misho Exp $"); php_info_print_table_row(2, "Phar-based phar archives", "enabled"); php_info_print_table_row(2, "Tar-based phar archives", "enabled"); php_info_print_table_row(2, "ZIP-based phar archives", "enabled");