]> granicus.if.org Git - php/commitdiff
Fix #78980: pgsqlGetNotify() overlooks dead connection
authorSATO Kentaro <kentaro@ranvis.com>
Tue, 17 Dec 2019 17:16:55 +0000 (02:16 +0900)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 20 Dec 2019 10:44:07 +0000 (11:44 +0100)
pgsqlGetNotify() didn't check result of PQconsumeInput().

NEWS
ext/pdo_pgsql/pgsql_driver.c

diff --git a/NEWS b/NEWS
index b178b9ddb8153a9b1348be481a17c8fccf2c039e..e38899f70e98e503d6b7871a96432c6920799b54 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,8 @@ PHP                                                                        NEWS
 - PDO_PgSQL:
   . Fixed bug #78983 (pdo_pgsql config.w32 cannot find libpq-fe.h). (SATŌ
     Kentarō)
+  . Fixed bug #78980 (pgsqlGetNotify() overlooks dead connection). (SATŌ
+    Kentarō)
 
 18 Dec 2019, PHP 7.3.13
 
index 64be3cd9b8c99caddfcfd33c6ea90e6fd861bf9c..1be0a6146e3d9bef86b011bf285bdcb245e65c12 100644 (file)
@@ -1071,13 +1071,21 @@ static PHP_METHOD(PDO, pgsqlGetNotify)
 
        H = (pdo_pgsql_db_handle *)dbh->driver_data;
 
-       PQconsumeInput(H->server);
+       if (!PQconsumeInput(H->server)) {
+               pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL);
+               PDO_HANDLE_DBH_ERR();
+               RETURN_FALSE;
+       }
        pgsql_notify = PQnotifies(H->server);
 
        if (ms_timeout && !pgsql_notify) {
                php_pollfd_for_ms(PQsocket(H->server), PHP_POLLREADABLE, (int)ms_timeout);
 
-               PQconsumeInput(H->server);
+               if (!PQconsumeInput(H->server)) {
+                       pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL);
+                       PDO_HANDLE_DBH_ERR();
+                       RETURN_FALSE;
+               }
                pgsql_notify = PQnotifies(H->server);
        }