Skip to content

Commit 501b15e

Browse files
committed
Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref
1 parent eb617f3 commit 501b15e

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
@@ -300,6 +300,12 @@ safe:
300300
}
301301

302302
plc->quoted = stmt->dbh->methods->quoter(stmt->dbh, buf, param_type);
303+
if (plc->quoted == NULL) {
304+
/* bork */
305+
ret = -1;
306+
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
307+
goto clean_up;
308+
}
303309
}
304310
}
305311

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)