Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lpBk9-00029p-8F for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Jun 2021 15:28:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lpBk8-0002c4-0C for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Jun 2021 15:28:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lpBk7-0002ZD-60 for pgsql-hackers@lists.postgresql.org; Fri, 04 Jun 2021 15:28:15 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lpBk1-0007ru-68 for pgsql-hackers@lists.postgresql.org; Fri, 04 Jun 2021 15:28:14 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 144785C012E; Fri, 4 Jun 2021 11:28:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 04 Jun 2021 11:28:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=6m6S3eg1alMxmE4Mrkp3s+6Heq9qO38Ge3PlNwdvXFk=; b=Sd3ZLiwl InvdjLVbzgXEYw5JLIs4RZGL07l/OSavSMIyMx9tHxyBFl6/1qIsK0nEF8OuUIZs 2ai7CezPe/ORzIr6kDVYERz+4o7V+qyEa+xqg9U9qvOkdixirp0W77Xq3AGTfDTr Z0tOiQcBRG8UiwMLq9klKp689knUZ/6Kbq0ub97AzJR/SwhEbqAKCOCNhEoCJAEo wtR4yKb+gI8GM38o9Z6DHXcoNXAn1L7QWEr08b8c71tUh1FCkcqAduWYm12RLfcm YGfHL6Vk/xBtI3VjD1MbD1c7EueRqvbxa+sWkZfW5PyT1Grz79vPgKkKYQSTFB9O WrGlK87A8eoK8Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedtuddgkeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttddunecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeehvdefueehiefhffegieeujeefvdeftedvfeffiedvkeel fffftdehleeujeelheenucffohhmrghinhepphhoshhtghhrrdgvshdpphhoshhtghhrvg hsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Jun 2021 11:28:06 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 127C72A0D0C; Fri, 4 Jun 2021 11:28:04 -0400 (-04) Date: Fri, 4 Jun 2021 11:28:04 -0400 From: Alvaro Herrera To: Bharath Rupireddy Cc: PostgreSQL Hackers Subject: Re: Incorrect usage of strtol, atoi for non-numeric junk inputs Message-ID: <202106041528.5gt6owi2kq6m@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Jun-04, Bharath Rupireddy wrote: > On Thu, May 27, 2021 at 3:05 AM Alvaro Herrera wrote: > > Hi, how is this related to > > https://postgr.es/m/20191028012000.GA59064@begriffs.com ? > > Thanks. The proposed approach there was to implement postgres's own > strtol i.e. string parsing, conversion to integers and use it in the > places where atoi is being used. I'm not sure how far that can go. > What I'm proposing here is to use strtol inplace of atoi to properly > detect errors in case of inputs like '1211efe', '-14adc' and so on as > atoi can't detect such errors. Thoughts? Well, if you scroll back to Surafel's initial submission in that thread, it looks very similar in spirit to what you have here. Another thing I just noticed which I hadn't realized is that Joe Nelson's patch depends on Fabien Coelho's patch in this other thread, https://www.postgresql.org/message-id/flat/alpine.DEB.2.21.1904201223040.29102@lancre which was closed as returned-with-feedback, I suppose mostly due to exhaustion/frustration at the lack of progress/interest. I would suggest that the best way forward in this area is to rebase both there patches on current master. -- Álvaro Herrera Valdivia, Chile "La virtud es el justo medio entre dos defectos" (Aristóteles)