Skip to content

ext/gettext: avoid NULL deref in textdomain/bindtextdomain#47

Closed
iliaal wants to merge 1 commit intoPHP-8.4from
gettext-null-deref-hardening-8.4
Closed

ext/gettext: avoid NULL deref in textdomain/bindtextdomain#47
iliaal wants to merge 1 commit intoPHP-8.4from
gettext-null-deref-hardening-8.4

Conversation

@iliaal
Copy link
Copy Markdown
Owner

@iliaal iliaal commented Apr 27, 2026

Both textdomain() and bindtextdomain($domain, $dir) can return NULL on libintl-internal allocation failure. RETURN_STRING then calls strlen(NULL) and crashes.

0221cee closed the same gap for bindtextdomain($domain, NULL). The other two sites get the same guard. textdomain() widens from string to string|false.

Both functions can return NULL on libintl-internal allocation failure.
The PHP wrappers passed the result directly to RETURN_STRING, which
calls strlen(NULL) and segfaults. Mirrors 0221cee, which closed
the same gap for bindtextdomain($domain, NULL).

textdomain()'s return type widens from string to string|false.
@iliaal iliaal force-pushed the gettext-null-deref-hardening-8.4 branch from a35fd15 to b7039f2 Compare April 27, 2026 01:21
@iliaal
Copy link
Copy Markdown
Owner Author

iliaal commented Apr 27, 2026

Superseded by php#21882.

@iliaal iliaal closed this Apr 27, 2026
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.

1 participant