Skip to content

Fix build with PHP 8.6: unserialize_callback_func is a zend_string - #419

Open
andypost wants to merge 2 commits into
igbinary:masterfrom
andypost:418-fix
Open

Fix build with PHP 8.6: unserialize_callback_func is a zend_string#419
andypost wants to merge 2 commits into
igbinary:masterfrom
andypost:418-fix

Conversation

@andypost

Copy link
Copy Markdown

php-src php/php-src@c82acefe470 (php 8.6.0beta1) converted the PG(unserialize_callback_func) global from char* to zend_string*.

Fixes #418

php-src commit c82acefe470 (php 8.6.0beta1) converted the
PG(unserialize_callback_func) global from char* to zend_string*.

Fixes igbinary#418
Covers the two cases the change touches and the existing tests miss:

- An empty unserialize_callback_func. Every way of setting the ini
  (php.ini, -d, -c, ini_set) stores a non-NULL zero-length zend_string;
  only a total absence of ini leaves the global NULL. Without the length
  check the empty name is called, raising
  'Invalid callback , function "" not found'.
- A callback that reassigns unserialize_callback_func while it runs. The
  warning has to name the callback that was actually called.

@remicollet remicollet left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, tested with 8.6.0beta1

@wyattoday

Copy link
Copy Markdown

Tested and works for us. Thanks @andypost !

@tricky , any chance you could review and merge so other people can get the fixes too?

eiriksm pushed a commit to violinist-dev/php-base that referenced this pull request Aug 15, 2026
My previous sed-based fix kept a raw char* into
PG(unserialize_callback_func)'s zend_string and re-read it later in
the same function, after invoking arbitrary user PHP code via the
unserialize callback -- if that callback reassigns
unserialize_callback_func, the original zend_string can be freed,
making the later read a use-after-free.

igbinary/igbinary#419 already fixes this upstream (not yet merged) by
taking an owned copy of the string up front. Cherry-pick that commit
instead of carrying a subtly unsafe patch of our own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KziZyXrwQuJyZeFPm1aQ6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fails to compile with php 8.6.0 beta 1

3 participants