Commit ed3e06a6738 for php.net
commit ed3e06a6738b5ab9b7ed8e92cda79832cd172ea1
Author: Daniel Scherzer <daniel.e.scherzer@gmail.com>
Date: Thu Jul 9 11:41:30 2026 -0700
GH-22658: avoid truncation on null bytes in `ReflectionConstant::__toString()`
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index e747a642778..661b1eb1f3a 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
index 5e1b855eed0..8b6a8e85c2f 100644
--- a/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt
+++ b/ext/reflection/tests/ReflectionConstant_null_byte_value.phpt
@@ -10,5 +10,5 @@
?>
--EXPECTF--
-Constant [ string DEMO ] { f }
+Constant [ string DEMO ] { f%0oo }
string(4) "f%0oo"