]> granicus.if.org Git - php/commitdiff
fix possible int overflow
authorAnatol Belski <ab@php.net>
Wed, 15 Apr 2015 14:11:35 +0000 (16:11 +0200)
committerAnatol Belski <ab@php.net>
Wed, 15 Apr 2015 15:57:27 +0000 (17:57 +0200)
ext/pdo_pgsql/pgsql_driver.c

index 8ea8ab248d53150fe62198c27734335fb73b3bf6..1c760dc94b7c7a19b6ed8cbf8437ecdcc1bda425 100644 (file)
@@ -1064,6 +1064,11 @@ static PHP_METHOD(PDO, pgsqlGetNotify)
        if (ms_timeout < 0) {
                php_error_docref(NULL, E_WARNING, "Invalid timeout");
                RETURN_FALSE;
+#if ZEND_ENABLE_ZVAL_LONG64
+       } else if (ms_timeout > INT_MAX) {
+               php_error_docref(NULL, E_WARNING, "timeout was shrinked to %d", INT_MAX);
+               ms_timeout = INT_MAX;
+#endif
        }
 
        H = (pdo_pgsql_db_handle *)dbh->driver_data;
@@ -1072,7 +1077,7 @@ static PHP_METHOD(PDO, pgsqlGetNotify)
        pgsql_notify = PQnotifies(H->server);
 
        if (ms_timeout && !pgsql_notify) {
-               php_pollfd_for_ms(PQsocket(H->server), PHP_POLLREADABLE, ms_timeout);
+               php_pollfd_for_ms(PQsocket(H->server), PHP_POLLREADABLE, (int)ms_timeout);
 
                PQconsumeInput(H->server);
                pgsql_notify = PQnotifies(H->server);