Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fix #77322: PharData::addEmptyDir('/') Possible integer overflow
This commit is contained in:
Christoph M. Becker 2020-12-15 11:45:35 +01:00
commit c2fbab392c
3 changed files with 28 additions and 2 deletions

4
NEWS
View File

@ -70,7 +70,9 @@ PHP NEWS
- Phar:
. Fixed bug #73809 (Phar Zip parse crash - mmap fail). (cmb)
. Fixed #75102 (`PharData` says invalid checksum for valid tar). (cmb)
. Fixed bug #75102 (`PharData` says invalid checksum for valid tar). (cmb)
. Fixed bug #77322 (PharData::addEmptyDir('/') Possible integer overflow).
(cmb)
- Phpdbg:
. Fixed bug #76813 (Access violation near NULL on source operand). (cmb)

View File

@ -0,0 +1,24 @@
--TEST--
Bug #77322 (PharData::addEmptyDir('/') Possible integer overflow)
--SKIPIF--
<?php
if (!extension_loaded('phar')) die('skip phar extension not available');
?>
--FILE--
<?php
$zip = new PharData(__DIR__ . '/bug77322.zip');
$zip->addEmptyDir('/');
var_dump($zip->count());
$tar = new PharData(__DIR__ . '/bug77322.tar');
$tar->addEmptyDir('/');
var_dump($tar->count());
?>
--EXPECT--
int(1)
int(1)
--CLEAN--
<?php
unlink(__DIR__ . '/bug77322.zip');
unlink(__DIR__ . '/bug77322.tar');
?>

View File

@ -567,7 +567,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, ch
} else {
etemp.flags = etemp.old_flags = PHAR_ENT_PERM_DEF_FILE;
}
if (is_dir) {
if (is_dir && path_len) {
etemp.filename_len--; /* strip trailing / */
path_len--;
}