mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.1' into PHP-8.2
This commit is contained in:
commit
25290cd25c
5 changed files with 54 additions and 5 deletions
|
@ -1626,7 +1626,8 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
|
|||
const char zip_magic[] = "PK\x03\x04";
|
||||
const char gz_magic[] = "\x1f\x8b\x08";
|
||||
const char bz_magic[] = "BZh";
|
||||
char *pos, test = '\0';
|
||||
char *pos;
|
||||
int recursion_count = 3; // arbitrary limit to avoid too deep or even infinite recursion
|
||||
const int window_size = 1024;
|
||||
char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */
|
||||
const zend_long readsize = sizeof(buffer) - sizeof(token);
|
||||
|
@ -1654,8 +1655,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
|
|||
MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated entry)")
|
||||
}
|
||||
|
||||
if (!test) {
|
||||
test = '\1';
|
||||
if (recursion_count) {
|
||||
pos = buffer+tokenlen;
|
||||
if (!memcmp(pos, gz_magic, 3)) {
|
||||
char err = 0;
|
||||
|
@ -1715,7 +1715,10 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
|
|||
compression = PHAR_FILE_COMPRESSED_GZ;
|
||||
|
||||
/* now, start over */
|
||||
test = '\0';
|
||||
if (!--recursion_count) {
|
||||
MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\"");
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
} else if (!memcmp(pos, bz_magic, 3)) {
|
||||
php_stream_filter *filter;
|
||||
|
@ -1753,7 +1756,10 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
|
|||
compression = PHAR_FILE_COMPRESSED_BZ2;
|
||||
|
||||
/* now, start over */
|
||||
test = '\0';
|
||||
if (!--recursion_count) {
|
||||
MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\"");
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
BIN
ext/phar/tests/bug81726.gz
Normal file
BIN
ext/phar/tests/bug81726.gz
Normal file
Binary file not shown.
14
ext/phar/tests/bug81726.phpt
Normal file
14
ext/phar/tests/bug81726.phpt
Normal file
|
@ -0,0 +1,14 @@
|
|||
--TEST--
|
||||
Bug #81726 (phar wrapper: DOS when using quine gzip file)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("phar")) die("skip phar extension not available");
|
||||
if (!extension_loaded("zlib")) die("skip zlib extension not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(fopen("phar://" . __DIR__ . "/bug81726.gz", "r"));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: fopen(phar://%s): failed to open stream: unable to decompress gzipped phar archive "%s" in %s on line %d
|
||||
bool(false)
|
15
ext/standard/tests/bug81727.phpt
Normal file
15
ext/standard/tests/bug81727.phpt
Normal file
|
@ -0,0 +1,15 @@
|
|||
--TEST--
|
||||
Bug #81727: $_COOKIE name starting with ..Host/..Secure should be discarded
|
||||
--COOKIE--
|
||||
..Host-test=ignore; __Host-test=correct; . Secure-test=ignore; . Elephpant=Awesome;
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump($_COOKIE);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
["__Host-test"]=>
|
||||
string(7) "correct"
|
||||
["__Elephpant"]=>
|
||||
string(7) "Awesome"
|
||||
}
|
|
@ -137,6 +137,20 @@ PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *trac
|
|||
}
|
||||
var_len = p - var;
|
||||
|
||||
/* Discard variable if mangling made it start with __Host-, where pre-mangling it did not start with __Host- */
|
||||
if (strncmp(var, "__Host-", sizeof("__Host-")-1) == 0 && strncmp(var_name, "__Host-", sizeof("__Host-")-1) != 0) {
|
||||
zval_ptr_dtor_nogc(val);
|
||||
free_alloca(var_orig, use_heap);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Discard variable if mangling made it start with __Secure-, where pre-mangling it did not start with __Secure- */
|
||||
if (strncmp(var, "__Secure-", sizeof("__Secure-")-1) == 0 && strncmp(var_name, "__Secure-", sizeof("__Secure-")-1) != 0) {
|
||||
zval_ptr_dtor_nogc(val);
|
||||
free_alloca(var_orig, use_heap);
|
||||
return;
|
||||
}
|
||||
|
||||
if (var_len==0) { /* empty variable name, or variable name with a space in it */
|
||||
zval_ptr_dtor_nogc(val);
|
||||
free_alloca(var_orig, use_heap);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue