|
|
| version 1.1.1.2, 2012/05/29 12:34:41 | version 1.1.1.5, 2014/06/15 20:03:53 |
|---|---|
| Line 2 | Line 2 |
| +----------------------------------------------------------------------+ | +----------------------------------------------------------------------+ |
| | phar php single-file executable PHP extension | | | phar php single-file executable PHP extension | |
| +----------------------------------------------------------------------+ | +----------------------------------------------------------------------+ |
| | Copyright (c) 2005-2012 The PHP Group | | | Copyright (c) 2005-2014 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 2579 int phar_flush(phar_archive_data *phar, char *user_stu | Line 2579 int phar_flush(phar_archive_data *phar, char *user_stu |
| php_serialize_data_t metadata_hash; | php_serialize_data_t metadata_hash; |
| smart_str main_metadata_str = {0}; | smart_str main_metadata_str = {0}; |
| int free_user_stub, free_fp = 1, free_ufp = 1; | int free_user_stub, free_fp = 1, free_ufp = 1; |
| int manifest_hack = 0; | |
| if (phar->is_persistent) { | if (phar->is_persistent) { |
| if (error) { | if (error) { |
| Line 2647 int phar_flush(phar_archive_data *phar, char *user_stu | Line 2648 int phar_flush(phar_archive_data *phar, char *user_stu |
| len = -len; | len = -len; |
| } | } |
| 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 (closeoldfile) { | if (closeoldfile) { |
| php_stream_close(oldfile); | php_stream_close(oldfile); |
| } | } |
| Line 2933 int phar_flush(phar_archive_data *phar, char *user_stu | Line 2931 int phar_flush(phar_archive_data *phar, char *user_stu |
| manifest_len = offset + phar->alias_len + sizeof(manifest) + main_metadata_str.len; | manifest_len = offset + phar->alias_len + sizeof(manifest) + main_metadata_str.len; |
| phar_set_32(manifest, manifest_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); | phar_set_32(manifest+4, new_manifest_count); |
| if (has_dirs) { | if (has_dirs) { |
| *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF); | *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF); |
| Line 3052 int phar_flush(phar_archive_data *phar, char *user_stu | Line 3056 int phar_flush(phar_archive_data *phar, char *user_stu |
| if (error) { | if (error) { |
| spprintf(error, 0, "unable to write temporary manifest of file \"%s\" to manifest of new phar \"%s\"", entry->filename, phar->fname); | spprintf(error, 0, "unable to write temporary manifest of file \"%s\" to manifest of new phar \"%s\"", entry->filename, phar->fname); |
| } | |
| 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; | return EOF; |