mirror of
https://github.com/php/php-src.git
synced 2025-01-27 14:13:41 +08:00
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78641: addGlob can modify given remove_path value
This commit is contained in:
commit
88e0d88897
3
NEWS
3
NEWS
@ -29,6 +29,9 @@ PHP NEWS
|
||||
. Fixed bug #76859 (stream_get_line skips data if used with data-generating
|
||||
filter). (kkopachev)
|
||||
|
||||
- Zip:
|
||||
. Fixed bug #78641 (addGlob can modify given remove_path value). (cmb)
|
||||
|
||||
03 Oct 2019, PHP 7.4.0RC3
|
||||
|
||||
- Core:
|
||||
|
@ -1645,7 +1645,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
|
||||
struct zip *intern;
|
||||
zval *self = ZEND_THIS;
|
||||
char *path = ".";
|
||||
char *remove_path = NULL;
|
||||
char *remove_path = NULL, *save_remove_path;
|
||||
char *add_path = NULL;
|
||||
size_t add_path_len, remove_path_len = 0, path_len = 1;
|
||||
zend_long remove_all_path = 0;
|
||||
@ -1677,10 +1677,11 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
save_remove_path = remove_path;
|
||||
if (remove_path && remove_path_len > 1) {
|
||||
size_t real_len = strlen(remove_path);
|
||||
if ((real_len > 1) && ((remove_path[real_len - 1] == '/') || (remove_path[real_len - 1] == '\\'))) {
|
||||
remove_path[real_len - 1] = '\0';
|
||||
remove_path = estrndup(remove_path, real_len - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1740,6 +1741,9 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
|
||||
}
|
||||
}
|
||||
}
|
||||
if (remove_path != save_remove_path) {
|
||||
efree(remove_path);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
28
ext/zip/tests/bug78641.phpt
Normal file
28
ext/zip/tests/bug78641.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #78641 (addGlob can modify given remove_path value)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('zip')) die('skip zip extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
define("TMPDIR", __DIR__ . "/");
|
||||
|
||||
$file = TMPDIR . 'bug78641';
|
||||
touch($file);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip->open(TMPDIR . "bug78641.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||
var_dump(basename(TMPDIR));
|
||||
$zip->addGlob($file, 0, ["remove_path" => TMPDIR]);
|
||||
var_dump(basename(TMPDIR));
|
||||
$zip->close();
|
||||
?>
|
||||
--EXPECT--
|
||||
string(5) "tests"
|
||||
string(5) "tests"
|
||||
--CLEAN--
|
||||
<?php
|
||||
unlink(__DIR__ . '/bug78641');
|
||||
unlink(__DIR__ . '/bug78641.zip');
|
||||
?>
|
Loading…
Reference in New Issue
Block a user