Fix bug #71391: NULL Pointer Dereference in phar_tar_setupmetadata()

This commit is contained in:
Stanislav Malyshev 2016-01-16 20:43:43 -08:00
parent 285cd3417f
commit 1c1b8b6998
3 changed files with 21 additions and 0 deletions

View File

@ -880,6 +880,9 @@ static int phar_tar_setupmetadata(void *pDest, void *argument TSRMLS_DC) /* {{{
if (entry->filename_len >= sizeof(".phar/.metadata") && !memcmp(entry->filename, ".phar/.metadata", sizeof(".phar/.metadata")-1)) {
if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.metadata.bin", sizeof(".phar/.metadata.bin")-1)) {
if (entry->phar->metadata == NULL) {
return ZEND_HASH_APPLY_REMOVE;
}
return phar_tar_setmetadata(entry->phar->metadata, entry, error TSRMLS_CC);
}
/* search for the file this metadata entry references */

View File

@ -0,0 +1,18 @@
--TEST--
Phar: bug #71391: NULL Pointer Dereference in phar_tar_setupmetadata()
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--FILE--
<?php
// duplicate since the tar will change
copy(__DIR__."/bug71391.tar", __DIR__."/bug71391.test.tar");
$p = new PharData(__DIR__."/bug71391.test.tar");
$p->delMetaData();
?>
DONE
--CLEAN--
<?php
unlink(__DIR__."/bug71391.test.tar");
?>
--EXPECT--
DONE

BIN
ext/phar/tests/bug71391.tar Normal file

Binary file not shown.