Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/pdo_pgsql/pgsql_sql_parser.re
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ int pdo_pgsql_scanner(pdo_scanner_t *s)
COMMENTS { RET(PDO_PARSER_TEXT); }
/* Plain text may contain e/E, as long as it doesn't end with one, which could start an E'...' string */
([eE]* TEXTCHR)+ { RET(PDO_PARSER_TEXT); }
* { SKIP_ONE(PDO_PARSER_TEXT); }
*/
}
32 changes: 32 additions & 0 deletions ext/pdo_pgsql/tests/gh24490.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
GH-24490 (pdo_pgsql: prepare() hangs on a query containing a NUL byte)
--EXTENSIONS--
pdo_pgsql
--SKIPIF--
<?php
require __DIR__ . '/config.inc';
require dirname(__DIR__, 2) . '/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

foreach ([true, false] as $emulate) {
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate);
$db->prepare("SELECT 'abc\0def'");
$db->prepare("\0SELECT 1");

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.

can we add this case too here ?

+    try {
+        $db->prepare("SELECT '\0', ?, :p");
+    } catch (\Throwable $e) {
+        echo $e::class, ": ", $e->getMessage(), "\n";
+    }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done, thanks.

try {
$db->prepare("SELECT '\0', ?, :p");
} catch (\Throwable $e) {
echo $e::class, ": ", $e->getMessage(), "\n";
}
}
echo "Done\n";
?>
--EXPECT--
PDOException: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters
PDOException: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters
Done
Loading