Skip to content

Commit 1c623e3

Browse files
committed
Fixed Bug #64949 (Buffer overflow in _pdo_pgsql_error)
There is a lot of call such as: pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed"); Where the 3rd paramater is a error message string where a sqlstate (5 chars) is expected. This cause a segfault in copy_from.phpt and copy_to.phpt. This is only a sanity check to avoid buffer overflow, but obviously this calls need to be fixed (using NULL or a correct sqlstate).
1 parent 13e5c97 commit 1c623e3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2013, PHP 5.3.27
44

5+
- PDO_pgsql:
6+
. Fixed Bug #64949 (Buffer overflow in _pdo_pgsql_error). (Remi)
7+
58
?? ??? 2013, PHP 5.3.26
69

710
### DO NOT ADD ENTRIES HERE, ADD THEM ABOVE FOR 5.3.27 ###

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
7676
einfo->errmsg = NULL;
7777
}
7878

79-
if (sqlstate == NULL) {
79+
if (sqlstate == NULL || strlen(sqlstate) >= sizeof(pdo_error_type)) {
8080
strcpy(*pdo_err, "HY000");
8181
}
8282
else {

0 commit comments

Comments
 (0)