Repository navigation
Fix GH-24490: pdo_pgsql prepare() hangs on a query containing a NUL byte - #24496
Closed
dev-null-undefined wants to merge 1 commit into
Closed
dev-null-undefined wants to merge 1 commit into
dev-null-undefined wants to merge 1 commit into
Conversation
dev-null-undefined
requested review from
SakiTakamachi and
devnexen
as code owners
October 21, 2026 18:50
devnexen
reviewed
Oct 21, 2026
| foreach ([true, false] as $emulate) { | ||
| $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate); | ||
| $db->prepare("SELECT 'abc\0def'"); | ||
| $db->prepare("\0SELECT 1"); |
Member
There was a problem hiding this comment.
can we add this case too here ?
+ try {
+ $db->prepare("SELECT '\0', ?, :p");
+ } catch (\Throwable $e) {
+ echo $e::class, ": ", $e->getMessage(), "\n";
+ }…L byte No rule in the scanner matches a NUL byte, so what re2c does with one is undefined. Before 5ccc56b it happened to skip one character. Now it returns a zero-length text token and pdo_parse_params() loops forever, or reads an uninitialized YYMARKER if the NUL is the first byte. Add a default rule so a NUL is skipped as one character of text again.
dev-null-undefined
force-pushed
the
gh24490
branch
from
October 21, 2026 20:48
e83b6b8 to
2c4971c
Compare
devnexen
approved these changes
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No rule in the scanner matches a NUL byte, so what re2c does with one is undefined. Before 5ccc56b it happened to skip one character. Now it returns a zero-length text token and
pdo_parse_params()loops forever, or reads an uninitializedYYMARKERif the NUL is the first byte. Add a default rule so a NUL is skipped as one character of text again. This also gets rid of re2c's-Wundefined-control-flowwarning for this scanner.The regression is only on master (GH-24353). The new test hangs without the fix, and the ext/pdo_pgsql tests pass against PostgreSQL 18.6.
Fixes #24490