Skip to content

Zend: Normalize empty string to NULL in OnUpdateStrNotEmpty - #23085

Closed
arshidkv12 wants to merge 3 commits into
php:masterfrom
arshidkv12:OnUpdateStrNotEmpty-1
Closed

Zend: Normalize empty string to NULL in OnUpdateStrNotEmpty#23085
arshidkv12 wants to merge 3 commits into
php:masterfrom
arshidkv12:OnUpdateStrNotEmpty-1

Conversation

@arshidkv12

Copy link
Copy Markdown
Contributor

@nicolas-grekas

Copy link
Copy Markdown
Contributor

This fixes the reported symptom, but OnUpdateStrNotEmpty is shared: output_handler, unserialize_callback_func, arg_separator.output, arg_separator.input, doc_root, sys_temp_dir, plus session.name and zend_test.not_empty_str_test. Making it accept empty and store NULL applies to all of them.

arg_separator.output is PHP_INI_ALL and its consumer has no NULL check (ext/standard/http.c#L118). With this patch applied:

$ php -r 'var_dump(ini_set("arg_separator.output", "")); var_dump(http_build_query(["a"=>1,"b"=>2]));'
string(1) "&"
Segmentation fault (core dumped)

On master that ini_set() returns false and nothing breaks.

It should also fail ext/zend_test/tests/zend_ini_str_validator_basic.phpt, which asserts ini_set("zend_test.not_empty_str_test", "") returns bool(false). That test exists to pin the difference between the two handlers.

OnUpdateStr and OnUpdateStrNotEmpty are a deliberate pair. c82acef just picked the wrong one for unserialize_callback_func, so the fix belongs on the entry:

-	STD_PHP_INI_ENTRY("unserialize_callback_func",	NULL,	PHP_INI_ALL,	OnUpdateStrNotEmpty,	unserialize_callback_func,	php_core_globals,	core_globals)
+	STD_PHP_INI_ENTRY("unserialize_callback_func",	NULL,	PHP_INI_ALL,	OnUpdateStr,	unserialize_callback_func,	php_core_globals,	core_globals)
 		/* Check for unserialize callback */
-		if (PG(unserialize_callback_func) == NULL) {
+		if (PG(unserialize_callback_func) == NULL || ZSTR_LEN(PG(unserialize_callback_func)) == 0) {
 			incomplete_class = 1;
 			ce = PHP_IC_ENTRY;
 			break;
 		}

The second hunk restores the empty check c82acef dropped, since OnUpdateStr stores an empty zend_string rather than NULL.

I built and checked that: the GH-23082 reproducer matches 8.5 output, arg_separator.output still rejects empty, the 13 tests in ext/standard/tests/serialize/unserialize_callback_func/ pass, and the Symfony suites that surfaced this are green again.

Your gh23082.phpt applies unchanged to that approach and is worth keeping.

@arshidkv12
arshidkv12 marked this pull request as draft August 6, 2026 12:40
Zend: Normalize empty string to NULL in OnUpdateStrNotEmpty

Zend: Normalize empty string to NULL in OnUpdateStrNotEmpty

Zend: Normalize empty string to NULL in OnUpdateStrNotEmpty

Zend: Normalize empty string to NULL in OnUpdateStrNotEmpty
@arshidkv12
arshidkv12 force-pushed the OnUpdateStrNotEmpty-1 branch from 4dbdf51 to 7e048fb Compare August 6, 2026 12:57
@arshidkv12

Copy link
Copy Markdown
Contributor Author

Thanks! You're right. Changing OnUpdateStrNotEmpty affects unrelated INI directives. Switching only unserialize_callback_func to OnUpdateStr and treating both NULL and "" as "no callback" fixes the regression without changing other directives.

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct fix.

@arshidkv12

Copy link
Copy Markdown
Contributor Author

Ok. Thank you

@arshidkv12 arshidkv12 closed this Aug 6, 2026
@arshidkv12
arshidkv12 deleted the OnUpdateStrNotEmpty-1 branch August 6, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants