*
* Meta-data is in this format:
* [len32][data...]
- *
+ *
* data is the serialized zval
*/
int phar_parse_metadata(char **buffer, zval **metadata, php_uint32 zip_metadata_len TSRMLS_DC) /* {{{ */
{
- const unsigned char *p;
php_unserialize_data_t var_hash;
if (zip_metadata_len) {
+ const unsigned char *p, *p_buff = estrndup(*buffer, zip_metadata_len);
+ p = p_buff;
ALLOC_ZVAL(*metadata);
INIT_ZVAL(**metadata);
- p = (const unsigned char*) *buffer;
PHP_VAR_UNSERIALIZE_INIT(var_hash);
if (!php_var_unserialize(metadata, &p, p + zip_metadata_len, &var_hash TSRMLS_CC)) {
+ efree(p_buff);
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
zval_ptr_dtor(metadata);
*metadata = NULL;
return FAILURE;
}
-
+ efree(p_buff);
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
if (PHAR_G(persist)) {
*
* Parse a new one and add it to the cache, returning either SUCCESS or
* FAILURE, and setting pphar to the pointer to the manifest entry
- *
+ *
* This is used by phar_open_from_filename to process the manifest, but can be called
* directly.
*/
/**
* Process a phar stream name, ensuring we can handle any of:
- *
+ *
* - whatever.phar
* - whatever.phar.gz
* - whatever.phar.bz2