1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4'

* PHP-8.4:
  Fix GH-17747: Exception on reading property in register-based FETCH_OBJ_R breaks JIT
  Fix GH-17745: zlib extension incorrectly handles object arguments
This commit is contained in:
Niels Dossche
2025-02-11 21:55:51 +01:00
6 changed files with 59 additions and 6 deletions

View File

@@ -0,0 +1,20 @@
--TEST--
GH-17745 (zlib extension incorrectly handles object arguments)
--EXTENSIONS--
zlib
--FILE--
<?php
$obj = new stdClass;
$obj->level = 3;
var_dump(deflate_init(ZLIB_ENCODING_RAW, $obj));
class Options {
public int $level = 3;
}
var_dump(deflate_init(ZLIB_ENCODING_RAW, new Options));
?>
--EXPECT--
object(DeflateContext)#2 (0) {
}
object(DeflateContext)#3 (0) {
}

View File

@@ -790,6 +790,7 @@ static bool zlib_create_dictionary_string(HashTable *options, char **dict, size_
zval *option_buffer;
if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("dictionary"))) != NULL) {
ZVAL_DEINDIRECT(option_buffer);
ZVAL_DEREF(option_buffer);
switch (Z_TYPE_P(option_buffer)) {
case IS_STRING: {
@@ -871,6 +872,7 @@ PHP_FUNCTION(inflate_init)
}
if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("window"))) != NULL) {
ZVAL_DEINDIRECT(option_buffer);
window = zval_get_long(option_buffer);
}
if (window < 8 || window > 15) {
@@ -1089,6 +1091,7 @@ PHP_FUNCTION(deflate_init)
}
if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("level"))) != NULL) {
ZVAL_DEINDIRECT(option_buffer);
level = zval_get_long(option_buffer);
}
if (level < -1 || level > 9) {
@@ -1097,6 +1100,7 @@ PHP_FUNCTION(deflate_init)
}
if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("memory"))) != NULL) {
ZVAL_DEINDIRECT(option_buffer);
memory = zval_get_long(option_buffer);
}
if (memory < 1 || memory > 9) {
@@ -1105,6 +1109,7 @@ PHP_FUNCTION(deflate_init)
}
if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("window"))) != NULL) {
ZVAL_DEINDIRECT(option_buffer);
window = zval_get_long(option_buffer);
}
if (window < 8 || window > 15) {
@@ -1113,6 +1118,7 @@ PHP_FUNCTION(deflate_init)
}
if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("strategy"))) != NULL) {
ZVAL_DEINDIRECT(option_buffer);
strategy = zval_get_long(option_buffer);
}
switch (strategy) {

View File

@@ -270,11 +270,11 @@ function gzread($stream, int $length): string|false {}
*/
function gzgets($stream, ?int $length = null): string|false {}
function deflate_init(int $encoding, array $options = []): DeflateContext|false {}
function deflate_init(int $encoding, array|object $options = []): DeflateContext|false {}
function deflate_add(DeflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false {}
function inflate_init(int $encoding, array $options = []): InflateContext|false {}
function inflate_init(int $encoding, array|object $options = []): InflateContext|false {}
function inflate_add(InflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false {}

View File

@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 65271ce06d23b397180a8dbbcecdb0cde5c6942b */
* Stub hash: 4c5bea6d9f290c244c7bb27c77fe8007d43a40db */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ob_gzhandler, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
@@ -106,7 +106,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_deflate_init, 0, 1, DeflateContext, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, encoding, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_ARG_TYPE_MASK(0, options, MAY_BE_ARRAY|MAY_BE_OBJECT, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_deflate_add, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
@@ -117,7 +117,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_inflate_init, 0, 1, InflateContext, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, encoding, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_ARG_TYPE_MASK(0, options, MAY_BE_ARRAY|MAY_BE_OBJECT, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_inflate_add, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)