diff --git a/NEWS b/NEWS index 2d0abd7eb42f..7324e5c591aa 100644 --- a/NEWS +++ b/NEWS @@ -65,6 +65,8 @@ PHP NEWS ReflectionParameter::__construct()). (jorgsowa) . Fixed bug GH-22441 (ReflectionClass::hasProperty() and getProperty() ignore dynamic properties shadowing a private parent property). (iliaal) + . Fixed bug GH-22658 (ReflectionConstant::__toString() with a string value + with null bytes truncates output). (DanielEScherzer) - Session: . Fixed bug GH-21314 (Different session garbage collector behavior between diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index e747a642778c..661b1eb1f3a4 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -585,7 +585,7 @@ static void _const_string(smart_str *str, const char *name, zval *value, const c if (Z_TYPE_P(value) == IS_ARRAY) { smart_str_append(str, ZSTR_KNOWN(ZEND_STR_ARRAY_CAPITALIZED)); } else if (Z_TYPE_P(value) == IS_STRING) { - smart_str_appends(str, Z_STRVAL_P(value)); + smart_str_append(str, Z_STR_P(value)); } else { zend_string *tmp_value_str; zend_string *value_str = zval_get_tmp_string(value, &tmp_value_str); diff --git a/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt b/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt new file mode 100644 index 000000000000..8b6a8e85c2fc --- /dev/null +++ b/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-22658: ReflectionConstant with a string value with a null byte +--FILE-- +getValue() ); + +?> +--EXPECTF-- +Constant [ string DEMO ] { f%0oo } +string(4) "f%0oo"