Skip to content

Commit 727a4dd

Browse files
committed
Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
1 parent c5f28c7 commit 727a4dd

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

ext/pdo/pdo_sql_parser.re

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ safe:
287287
}
288288

289289
plc->quoted = stmt->dbh->methods->quoter(stmt->dbh, buf, param_type);
290+
if (plc->quoted == NULL) {
291+
/* bork */
292+
ret = -1;
293+
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
294+
goto clean_up;
295+
}
290296
}
291297
}
292298

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
#GHSA-8xr5-qppj-gvwj: NULL Pointer Derefernce for failed user input quoting
3+
--EXTENSIONS--
4+
pdo
5+
pdo_pgsql
6+
--SKIPIF--
7+
<?php
8+
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
9+
require_once dirname(__FILE__) . '/config.inc';
10+
PDOTest::skip();
11+
?>
12+
--FILE--
13+
<?php
14+
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
15+
require_once dirname(__FILE__) . '/config.inc';
16+
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
17+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
18+
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
19+
20+
$sql = "SELECT * FROM users where username = :username";
21+
$stmt = $db->prepare($sql);
22+
23+
$p1 = "alice\x99";
24+
var_dump($stmt->execute(['username' => $p1]));
25+
26+
?>
27+
--EXPECT--
28+
bool(false)

0 commit comments

Comments
 (0)