From be067eb3c7c87e70e6a3604d936a5c688d5bb1e7 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Fri, 14 Apr 2023 02:46:26 +0900 Subject: [PATCH v2 2/2] Improve PQconnectPoll by strictly parsing the keepalives parameter. Commit e7a2217978 introduced the parse_int_param() function to parse libpq connection parameters more strictly. However, PQconnectPoll() was not updated to use parse_int_param() when parsing the keepalives parameter. This caused inconsistency in the handling of the same parameter between PQconnectPoll() and PQgetCancel(). This commit resolves the issue by using parse_int_param() to parse the keepalives parameter in useKeepalives() called in PQconnectPoll(). By parsing the keepalives parameter more strictly, the behavior of PQconnectPoll() is now consistent with PQgetCancel(). --- src/interfaces/libpq/fe-connect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 6558d098b5..e626d50366 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -2067,14 +2067,14 @@ connectFailureMessage(PGconn *conn, int errorno) static int useKeepalives(PGconn *conn) { - char *ep; int val; if (conn->keepalives == NULL) return 1; - val = strtol(conn->keepalives, &ep, 10); - if (*ep) + + if (!parse_int_param(conn->keepalives, &val, conn, "keepalives")) return -1; + return val != 0 ? 1 : 0; } -- 2.40.0