Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iMr3Q-0001Ou-5w for pgsql-committers@arkaria.postgresql.org; Tue, 22 Oct 2019 10:06:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iMr3O-0004iy-Sg for pgsql-committers@arkaria.postgresql.org; Tue, 22 Oct 2019 10:06:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iMr3N-0004ir-AI for pgsql-committers@lists.postgresql.org; Tue, 22 Oct 2019 10:06:14 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iMr3H-0004nA-M9 for pgsql-committers@lists.postgresql.org; Tue, 22 Oct 2019 10:06:12 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 1A2F92071B; Tue, 22 Oct 2019 06:06:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 22 Oct 2019 06:06:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=KL44G+vXAVe2K96HDq1j9VwmpsS nZ2KeF1+6DqioZJA=; b=TryKsVWTXEpFxrV6XJPNGOBVvzrpdD1NhY5qsOfgm+5 tSjL7qOQLUCSHLBpJ/PG1BONLimeAiMKLLhIoruA3p8ibjJZkD871QmYRp5EUP5N aeWDG8BRyVgvTzxe6US6yJoFfWArIZgDTDgapEgHEoUcfp1k3yo/2VEbUiuOs+Qn HgetJkSTKSW0GRyUQefkwczbvN0S/dOeT5Ll12NBOa39cyqaFQDXk24tWECnmTq5 43oVdHZ92JWyAbrN2gd0WirPqxmv5JvCJOnJqXS4siQCrciWuQVzZNKS5qwAigcz 04E+k3ZwnJzHLJvxKqcv35Y6UvceHUDdptuoCA7njIQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=KL44G+ vXAVe2K96HDq1j9VwmpsSnZ2KeF1+6DqioZJA=; b=fbOS/1qz+ASlXh9LKC5v8z v3PgE1j7pRjiTCKNsnHIPPCeKcZ4yTpQuHw+jVmJTN2YWtgUiVzY+xgoqq1bM4rY gdqW+h7PscsY7Nst4Kkq/kYtHbl2HDnRNCjzrX+0s8DhdIlsbbiOkL93NSfn5bek POCdk0d+u1V0AjCsNTh78Is61a0t3Quosw42f9sayhGKbv4TH7XLqSRj93a2OMuD JwmwRsmiMOtQiNIYztYs1c1HO+J6nLZU8qaNMRMJMKQ+bi7zmZZTfaMAPAsy6+Jm VsAXmmxTeQOwfyLgEaPD7vvtxhX04rK1LI8C1LKxRizm0Bt4hZFT6+0HVyxceLTw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrkeejgddvgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecukfhppeduuddurddutddvrddukedtrddukeehnecurfgrrhgr mhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiinecuvehluh hsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 23670804A2; Tue, 22 Oct 2019 06:05:57 -0400 (EDT) Date: Tue, 22 Oct 2019 19:05:53 +0900 From: Michael Paquier To: Peter Eisentraut Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix parsing of integer values for connection parameters in libpq Message-ID: <20191022100553.GA3908@paquier.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cmJC7u66zC7hs+87" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --cmJC7u66zC7hs+87 Content-Type: multipart/mixed; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 22, 2019 at 10:05:45AM +0200, Peter Eisentraut wrote: > You probably want something like >=20 > if (end && *end !=3D ...) Yes, it looks like a brain fade here. Conversion failures are tracked before that, so strtol() would not return NULL for endptr. The first part could just be removed as per the attached.=20 -- Michael --HlL+5n6rz5pIUxbD Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="libpq-parse-fix.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-co= nnect.c index 9af830321c..0eeabb8b43 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -1713,10 +1713,10 @@ parse_int_param(const char *value, int *result, PGc= onn *conn, * Skip any trailing whitespace; if anything but whitespace remains before * the terminating character, fail */ - while (*end && *end !=3D '\0' && isspace((unsigned char) *end)) + while (*end !=3D '\0' && isspace((unsigned char) *end)) end++; =20 - if (*end && *end !=3D '\0') + if (*end !=3D '\0') goto error; =20 *result =3D numval; --HlL+5n6rz5pIUxbD-- --cmJC7u66zC7hs+87 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl2u1IEACgkQnvQgOdby QH3RPxAAhuydd/4TZJboCTFg2A+CKUD+B9HxqJqy5C9sXWtDsc8IC+f5EDL9Tp/n xbWIFS/3TuW+wUZjiq/fDNtgpG+jbw3ztYqyACzYuK3nuboxwsK9ocHZ1Ez/NJJ+ PvTcr6wTq6dw6kiVDplzvnEtSBTOOQhzaEWuH3RCI8XQO5pgMkENx2U0+BetCdRZ IRPh54RQNAgh11nKXzLlj8543JWH1S4h7P2zfn34kCQ8bo6EIqmQP9yj13oNGMkv rWOtU5sP6xLkbJS1joAjZUc+XBWNaEv51c87qjTK8nToYvgi2LzMhO4Jr6lIFH8S fkz3Yz4vZaVUt1v7bpe3lMvzVNricaJpswnpXyKYhyltvy2iEitV/xLCI77lHn/X od3LDHzXWPAe3aVVCUny9VaGD6fVU3DxoLn8B33VuG51N3e/mnKx/NZhdeHBndtz 7gIDdxYu8fkC4+msPj7xwmmFWuuyXgZDLJW9r9QbJd8KAr6C/WoctWqkhJwSX7Bc GnIpbubZUmxbzeBcePdGYJE9Ve50cC31n4uVReBWdCXBY4BEfgc7ajdHfXu4xusj UUPRbsyDV6c4n6KWqdmibg88AwQntgeGdSJoVJIihfQnWvBfG0jKAYPmHfZhQthZ nUF8KxXSrRBlxv1Gyg0o5RjaMwdIzCv3x3Uo/KrBjlV0SdSbgKI= =f059 -----END PGP SIGNATURE----- --cmJC7u66zC7hs+87--