Skip to content

Commit 12d3bde

Browse files
committed
Additional fix for bug #69324
Not so happy about duplication but needed due to bug #69429
1 parent a894a81 commit 12d3bde

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ext/phar/phar.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,27 +600,28 @@ int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len
600600
*
601601
* Meta-data is in this format:
602602
* [len32][data...]
603-
*
603+
*
604604
* data is the serialized zval
605605
*/
606606
int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_len TSRMLS_DC) /* {{{ */
607607
{
608-
const unsigned char *p;
609608
php_unserialize_data_t var_hash;
610609

611610
if (zip_metadata_len) {
611+
const unsigned char *p, *p_buff = estrndup(*buffer, zip_metadata_len);
612+
p = p_buff;
612613
ALLOC_ZVAL(*metadata);
613614
INIT_ZVAL(**metadata);
614-
p = (const unsigned char*) *buffer;
615615
PHP_VAR_UNSERIALIZE_INIT(var_hash);
616616

617617
if (!php_var_unserialize(metadata, &p, p + zip_metadata_len, &var_hash TSRMLS_CC)) {
618+
efree(p_buff);
618619
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
619620
zval_ptr_dtor(metadata);
620621
*metadata = NULL;
621622
return FAILURE;
622623
}
623-
624+
efree(p_buff);
624625
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
625626

626627
if (PHAR_G(persist)) {
@@ -643,7 +644,7 @@ int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_
643644
*
644645
* Parse a new one and add it to the cache, returning either SUCCESS or
645646
* FAILURE, and setting pphar to the pointer to the manifest entry
646-
*
647+
*
647648
* This is used by phar_open_from_filename to process the manifest, but can be called
648649
* directly.
649650
*/
@@ -2236,7 +2237,7 @@ char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC) /* {{{
22362237

22372238
/**
22382239
* Process a phar stream name, ensuring we can handle any of:
2239-
*
2240+
*
22402241
* - whatever.phar
22412242
* - whatever.phar.gz
22422243
* - whatever.phar.bz2

0 commit comments

Comments
 (0)