diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-12-15 11:45:35 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-12-15 11:46:28 +0100 |
commit | c2fbab392c5b25aeb2daf243f4107557416942fb (patch) | |
tree | af46f68a36ea048f930f79ba0c3983a0df179834 /ext/phar | |
parent | 305500a3b1777c5c5441f18746d6fe9124646c35 (diff) | |
parent | a53d67ceac301cbd27c4f0f716d4fbcdb7db3407 (diff) | |
download | php-git-c2fbab392c5b25aeb2daf243f4107557416942fb.tar.gz |
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
Fix #77322: PharData::addEmptyDir('/') Possible integer overflow
Diffstat (limited to 'ext/phar')
-rw-r--r-- | ext/phar/tests/bug77322.phpt | 24 | ||||
-rw-r--r-- | ext/phar/util.c | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/ext/phar/tests/bug77322.phpt b/ext/phar/tests/bug77322.phpt new file mode 100644 index 0000000000..b9e5ce4dba --- /dev/null +++ b/ext/phar/tests/bug77322.phpt @@ -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'); +?> diff --git a/ext/phar/util.c b/ext/phar/util.c index 6c084d8458..b45251d14a 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -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--; } |