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 1pcGDC-0005gC-0q for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Mar 2023 01:45:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pcGD9-0001gq-On for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Mar 2023 01:45:51 +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 1pcGD9-0001gh-GR for pgsql-bugs@lists.postgresql.org; Wed, 15 Mar 2023 01:45:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcGD7-0007sR-0h for pgsql-bugs@lists.postgresql.org; Wed, 15 Mar 2023 01:45:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 32F1jk5r3076957; Tue, 14 Mar 2023 21:45:46 -0400 From: Tom Lane To: Thiago Nunes cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17839: Heap-buffer overflow on float8_to_char with invalid template In-reply-to: References: <17839-aada50db24d7b0da@postgresql.org> <3011659.1678834145@sss.pgh.pa.us> Comments: In-reply-to Thiago Nunes message dated "Wed, 15 Mar 2023 12:17:38 +1100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3076955.1678844746.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 14 Mar 2023 21:45:46 -0400 Message-ID: <3076956.1678844746@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thiago Nunes writes: > I think your solution deals with all the cases, but I would like to poin= t > out how I fixed it locally. I recalculated Num.zero_end after this line = ( > https://github.com/postgres/postgres/blob/REL_15_2/src/backend/utils/adt= /formatting.c#L6716 > ): > ``` > Num.zero_end =3D Num.pre + Num.post; > ``` Hmm ... that seems a bit ad-hoc, because as far as I understand this code, zero_end is supposed to track where is the last '0' format character. That shouldn't change just because we decided that the data value overflowed. regards, tom lane