@@ -600,27 +600,28 @@ int phar_open_parsed_phar(char *fname, int fname_len, char *alias, int alias_len
600
600
*
601
601
* Meta-data is in this format:
602
602
* [len32][data...]
603
- *
603
+ *
604
604
* data is the serialized zval
605
605
*/
606
606
int phar_parse_metadata (char * * buffer , zval * * metadata , php_uint32 zip_metadata_len TSRMLS_DC ) /* {{{ */
607
607
{
608
- const unsigned char * p ;
609
608
php_unserialize_data_t var_hash ;
610
609
611
610
if (zip_metadata_len ) {
611
+ const unsigned char * p , * p_buff = estrndup (* buffer , zip_metadata_len );
612
+ p = p_buff ;
612
613
ALLOC_ZVAL (* metadata );
613
614
INIT_ZVAL (* * metadata );
614
- p = (const unsigned char * ) * buffer ;
615
615
PHP_VAR_UNSERIALIZE_INIT (var_hash );
616
616
617
617
if (!php_var_unserialize (metadata , & p , p + zip_metadata_len , & var_hash TSRMLS_CC )) {
618
+ efree (p_buff );
618
619
PHP_VAR_UNSERIALIZE_DESTROY (var_hash );
619
620
zval_ptr_dtor (metadata );
620
621
* metadata = NULL ;
621
622
return FAILURE ;
622
623
}
623
-
624
+ efree ( p_buff );
624
625
PHP_VAR_UNSERIALIZE_DESTROY (var_hash );
625
626
626
627
if (PHAR_G (persist )) {
@@ -643,7 +644,7 @@ int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_
643
644
*
644
645
* Parse a new one and add it to the cache, returning either SUCCESS or
645
646
* FAILURE, and setting pphar to the pointer to the manifest entry
646
- *
647
+ *
647
648
* This is used by phar_open_from_filename to process the manifest, but can be called
648
649
* directly.
649
650
*/
@@ -2236,7 +2237,7 @@ char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC) /* {{{
2236
2237
2237
2238
/**
2238
2239
* Process a phar stream name, ensuring we can handle any of:
2239
- *
2240
+ *
2240
2241
* - whatever.phar
2241
2242
* - whatever.phar.gz
2242
2243
* - whatever.phar.bz2
0 commit comments