Skip to content

Commit 7e39e69

Browse files
ranvisnikic
authored andcommitted
Fix #78980: pgsqlGetNotify() overlooks dead connection
pgsqlGetNotify() didn't check result of PQconsumeInput().
1 parent c62cd9a commit 7e39e69

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ PHP NEWS
2424
- PDO_PgSQL:
2525
. Fixed bug #78983 (pdo_pgsql config.w32 cannot find libpq-fe.h). (SATŌ
2626
Kentarō)
27+
. Fixed bug #78980 (pgsqlGetNotify() overlooks dead connection). (SATŌ
28+
Kentarō)
2729

2830
18 Dec 2019, PHP 7.3.13
2931

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,13 +1071,21 @@ static PHP_METHOD(PDO, pgsqlGetNotify)
10711071

10721072
H = (pdo_pgsql_db_handle *)dbh->driver_data;
10731073

1074-
PQconsumeInput(H->server);
1074+
if (!PQconsumeInput(H->server)) {
1075+
pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL);
1076+
PDO_HANDLE_DBH_ERR();
1077+
RETURN_FALSE;
1078+
}
10751079
pgsql_notify = PQnotifies(H->server);
10761080

10771081
if (ms_timeout && !pgsql_notify) {
10781082
php_pollfd_for_ms(PQsocket(H->server), PHP_POLLREADABLE, (int)ms_timeout);
10791083

1080-
PQconsumeInput(H->server);
1084+
if (!PQconsumeInput(H->server)) {
1085+
pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL);
1086+
PDO_HANDLE_DBH_ERR();
1087+
RETURN_FALSE;
1088+
}
10811089
pgsql_notify = PQnotifies(H->server);
10821090
}
10831091

0 commit comments

Comments
 (0)