mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-20882: phar buildFromIterator breaks with missing base directory
Broke in f57526a07a because of changing a char*+size_t pair to
zend_string* (which can't handle NULL pointers in its macros).
Closes GH-20888.
This commit is contained in:
4
NEWS
4
NEWS
@@ -10,6 +10,10 @@ PHP NEWS
|
||||
. Fixed bug GH-20833 (mb_str_pad() divide by zero if padding string is
|
||||
invalid in the encoding). (ndossche)
|
||||
|
||||
- Phar:
|
||||
. Fixed bug GH-20882 (buildFromIterator breaks with missing base directory).
|
||||
(ndossche)
|
||||
|
||||
- Readline:
|
||||
. Fixed bug GH-18139 (Memory leak when overriding some settings
|
||||
via readline_info()). (ndossche)
|
||||
|
||||
@@ -1397,12 +1397,12 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
|
||||
zval *value;
|
||||
bool close_fp = 1;
|
||||
struct _phar_t *p_obj = (struct _phar_t*) puser;
|
||||
size_t str_key_len, base_len = ZSTR_LEN(p_obj->base);
|
||||
size_t str_key_len, base_len = p_obj->base ? ZSTR_LEN(p_obj->base) : 0;
|
||||
phar_entry_data *data;
|
||||
php_stream *fp;
|
||||
size_t fname_len;
|
||||
size_t contents_len;
|
||||
char *fname, *error = NULL, *base = ZSTR_VAL(p_obj->base), *save = NULL, *temp = NULL;
|
||||
char *fname, *error = NULL, *base = p_obj->base ? ZSTR_VAL(p_obj->base) : NULL, *save = NULL, *temp = NULL;
|
||||
zend_string *opened;
|
||||
char *str_key;
|
||||
zend_class_entry *ce = p_obj->c;
|
||||
|
||||
22
ext/phar/tests/gh20882.phpt
Normal file
22
ext/phar/tests/gh20882.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
GH-20882 (phar buildFromIterator breaks with missing base directory)
|
||||
--EXTENSIONS--
|
||||
phar
|
||||
--INI--
|
||||
phar.readonly=0
|
||||
--FILE--
|
||||
<?php
|
||||
$phar = new \Phar(__DIR__ . "/test.phar");
|
||||
try {
|
||||
$phar->buildFromIterator(
|
||||
new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator(__DIR__.'/test79082', FilesystemIterator::SKIP_DOTS)
|
||||
),
|
||||
null
|
||||
);
|
||||
} catch (BadMethodCallException $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Iterator RecursiveIteratorIterator returns an SplFileInfo object, so base directory must be specified
|
||||
Reference in New Issue
Block a user