From 4ba42f6b07c708ee1369cd454ecab25e87d83e86 Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Tue, 14 Jul 2026 13:51:49 +0200 Subject: [PATCH 1/5] curl: Use correct format string in curl debug messages (#22723) Use `%p` for pointers, `%zu` for size_t. This only applies when PHP_CURL_DEBUG is enabled. If so, it solves compiler warnings, avoids undefined behavior and prints values correctly. --- ext/curl/interface.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index b7ec015abf62..c0286069776e 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -528,7 +528,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) #if PHP_CURL_DEBUG fprintf(stderr, "curl_write() called\n"); - fprintf(stderr, "data = %s, size = %d, nmemb = %d, ctx = %x\n", data, size, nmemb, ctx); + fprintf(stderr, "data = %s, size = %zu, nmemb = %zu, ctx = %p\n", data, size, nmemb, (void *) ctx); #endif switch (write_handler->method) { @@ -610,7 +610,7 @@ static int curl_progress(void *clientp, double dltotal, double dlnow, double ult #if PHP_CURL_DEBUG fprintf(stderr, "curl_progress() called\n"); - fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow); + fprintf(stderr, "clientp = %p, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow); #endif if (!ZEND_FCC_INITIALIZED(ch->handlers.progress)) { return rval; @@ -651,7 +651,7 @@ static int curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, cu #if PHP_CURL_DEBUG fprintf(stderr, "curl_xferinfo() called\n"); - fprintf(stderr, "clientp = %x, dltotal = %ld, dlnow = %ld, ultotal = %ld, ulnow = %ld\n", clientp, dltotal, dlnow, ultotal, ulnow); + fprintf(stderr, "clientp = %p, dltotal = %ld, dlnow = %ld, ultotal = %ld, ulnow = %ld\n", clientp, dltotal, dlnow, ultotal, ulnow); #endif if (!ZEND_FCC_INITIALIZED(ch->handlers.xferinfo)) { return rval; @@ -746,7 +746,7 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key, #if PHP_CURL_DEBUG fprintf(stderr, "curl_ssh_hostkeyfunction() called\n"); - fprintf(stderr, "clientp = %x, keytype = %d, key = %s, keylen = %zu\n", clientp, keytype, key, keylen); + fprintf(stderr, "clientp = %p, keytype = %d, key = %s, keylen = %zu\n", clientp, keytype, key, keylen); #endif zval args[4]; @@ -843,7 +843,7 @@ static int curl_seek(void *clientp, curl_off_t offset, int origin) #if PHP_CURL_DEBUG fprintf(stderr, "curl_seek() called\n"); - fprintf(stderr, "clientp = %x, offset = %ld, origin = %d\n", clientp, offset, origin); + fprintf(stderr, "clientp = %p, offset = %ld, origin = %d\n", clientp, offset, origin); #endif if (!ZEND_FCC_INITIALIZED(ch->handlers.seek)) { return rval; @@ -2801,7 +2801,7 @@ static void curl_free_obj(zend_object *object) php_curl *ch = curl_from_obj(object); #if PHP_CURL_DEBUG - fprintf(stderr, "DTOR CALLED, ch = %x\n", ch); + fprintf(stderr, "DTOR CALLED, ch = %p\n", (void *) ch); #endif if (!ch->cp) { From 7d1118b3c8f153843c9f005faf22dba01443a966 Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Tue, 14 Jul 2026 13:04:28 +0000 Subject: [PATCH 2/5] [ci skip] Update NEWS for 8.6.0alpha3 --- NEWS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6f2e69aa8294..84f532f19afe 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? ????, PHP 8.6.0alpha2 +?? ??? ????, PHP 8.6.0alpha3 + + +16 Jul 2026, PHP 8.6.0alpha2 - Core: . Sync Boost.Context assembly with 1.91.0. (kn1g78) From 0fca39de812864a4262c1734143cafdd0efdd399 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Mon, 13 Jul 2026 14:30:19 -0700 Subject: [PATCH 3/5] Add regression tests for `ReflectionEnum::__toString()` with null bytes So that when the output is fixed the changes can be confirmed in tests --- .../gh22681/ReflectionEnum_backed_value.phpt | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt diff --git a/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt b/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt new file mode 100644 index 000000000000..8131a3adafed --- /dev/null +++ b/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt @@ -0,0 +1,61 @@ +--TEST-- +GH-22681: null bytes in backed value truncate ReflectionEnum::__toString() +--FILE-- +getBackingValue() ); +?> +--EXPECTF-- +Enum [ enum Demo: string implements UnitEnum, BackedEnum ] { + @@ %s %d-%d + + - Enum cases [1] { + Case DEMO = F + } + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [3] { + Method [ static public method cases ] { + + - Parameters [0] { + } + - Return [ array ] + } + + Method [ static public method from ] { + + - Parameters [1] { + Parameter #0 [ string|int $value ] + } + - Return [ static ] + } + + Method [ static public method tryFrom ] { + + - Parameters [1] { + Parameter #0 [ string|int $value ] + } + - Return [ ?static ] + } + } + + - Properties [2] { + Property [ public protected(set) readonly string $name ] + Property [ public protected(set) readonly string $value ] + } + + - Methods [0] { + } +} +string(4) "F%0oo" From 1b2c0abbdb333cbe350aff69904f3312c55c18f1 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Mon, 13 Jul 2026 14:34:10 -0700 Subject: [PATCH 4/5] GH-22681: avoid truncation on null bytes in `ReflectionEnum::__toString()` --- ext/reflection/php_reflection.c | 8 ++++++-- .../tests/gh22681/ReflectionEnum_backed_value.phpt | 2 +- .../tests/gh22681/ReflectionEnum_case_doc_comment.phpt | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index a3e996b654c1..bf7fde62d499 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -677,7 +677,9 @@ static void _enum_case_string(smart_str *str, const zend_string *name, zend_clas } if (c->doc_comment) { - smart_str_append_printf(str, "%s%s\n", indent, ZSTR_VAL(c->doc_comment)); + smart_str_appends(str, indent); + smart_str_append(str, c->doc_comment); + smart_str_appendc(str, '\n'); } smart_str_append_printf(str, "%sCase %s", indent, ZSTR_VAL(name)); if (c->ce->enum_backing_type == IS_UNDEF) { @@ -691,7 +693,9 @@ static void _enum_case_string(smart_str *str, const zend_string *name, zend_clas zval *enum_val = zend_enum_fetch_case_value(Z_OBJ(c->value)); zend_string *tmp_value_str; zend_string *value_str = zval_get_tmp_string(enum_val, &tmp_value_str); - smart_str_append_printf(str, " = %s\n", ZSTR_VAL(value_str)); + smart_str_appends(str, " = "); + smart_str_append(str, value_str); + smart_str_appendc(str, '\n'); zend_tmp_string_release(tmp_value_str); } } diff --git a/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt b/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt index 8131a3adafed..f28c39daa100 100644 --- a/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt +++ b/ext/reflection/tests/gh22681/ReflectionEnum_backed_value.phpt @@ -16,7 +16,7 @@ Enum [ enum Demo: string implements UnitEnum, BackedEnum ] { @@ %s %d-%d - Enum cases [1] { - Case DEMO = F + Case DEMO = F%0oo } - Constants [0] { diff --git a/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt b/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt index 68bde0bed637..3945ad8639e7 100644 --- a/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt +++ b/ext/reflection/tests/gh22681/ReflectionEnum_case_doc_comment.phpt @@ -20,7 +20,7 @@ Enum [ enum Demo implements UnitEnum ] { @@ %s(%d) : eval()'d code %d-%d - Enum cases [1] { - /** F + /** F%0oo */ Case C } From e2c975d4fcc2769cac8a6c94e5d5b634a11ffbfb Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Tue, 14 Jul 2026 06:39:29 -0700 Subject: [PATCH 5/5] Update NEWS This just missed the alpha2 tag so needs a new entry for alpha3 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 84f532f19afe..01ab6b2a97a1 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.6.0alpha3 +- Reflection: + . Fixed bug GH-22681 (Reflection*::__toString() truncates on null bytes). + (DanielEScherzer) 16 Jul 2026, PHP 8.6.0alpha2