Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6WPo-00DYEx-Q4 for pgsql-committers@arkaria.postgresql.org; Thu, 31 Oct 2024 14:44:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t6WPm-0026Hl-AE for pgsql-committers@arkaria.postgresql.org; Thu, 31 Oct 2024 14:44:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6WPm-0026Hd-00 for pgsql-committers@lists.postgresql.org; Thu, 31 Oct 2024 14:44:46 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6WPf-00411Z-FO for pgsql-committers@lists.postgresql.org; Thu, 31 Oct 2024 14:44:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2024011501; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=asu/VLKW73E7WBupvH4olgaOgu/+Qgax1rObz14JmtM=; b=Cs3Kp JO/xAHzsjNOIBLg4FCmTsAkNJYUVgFw+IaSZgPkLB66Jzgk0m2NA73cArKo3xDMAVcjQz19TOuLLF 40nWgyvnSJuwZGl3KDn+I9glD2DbHR/U2nCSXQQY+yRF5hjDgzBTWfc0ObUIJkjCcNBp2+bsyXove Vmu1GIpxRqBH2MQx+DyEu1Hd+Wu4NaGBU+Kt5/RE8L+iHudlixHoAlkBNUZ7BLvX5vESE3ydePtGI 1384trAgml+4jRRTN4TgdtFzwIoZGqDKncCPXHxQc6ExqolXyAc8awQQRZnZy1CrUmm7g2057QclA SeANaUYrNk9wS9AU3PAL44vXxSx4w==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1t6WPc-0036N3-36; Thu, 31 Oct 2024 10:44:36 -0400 Date: Thu, 31 Oct 2024 10:44:36 -0400 From: Bruce Momjian To: Michael Paquier Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: ecpg: Fix out-of-bound read in DecodeDateTime() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Great, thanks for applying this. I was traveling so am only now back to looking at this. --------------------------------------------------------------------------- On Tue, Oct 22, 2024 at 11:35:51PM +0000, Michael Paquier wrote: > ecpg: Fix out-of-bound read in DecodeDateTime() > > It was possible for the code to read out-of-bound data from the > "day_tab" table with some crafted input data. Let's treat these as > invalid input as the month number is incorrect. > > A test is added to test this case with a check on the errno returned by > the decoding routine. A test close to the new one added in this commit > was testing for a failure, but did not look at the errno generated, so > let's use this commit to also change it, adding a check on the errno > returned by DecodeDateTime(). > > Like the other test scripts, dt_test should likely be expanded to > include more checks based on the errnos generated in these code paths. > This is left as future work. > > This issue exists since 2e6f97560a83, so backpatch all the way down. > > Reported-by: Pavel Nekrasov > Author: Bruce Momjian, Pavel Nekrasov > Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org > Backpatch-through: 12 > > Branch > ------ > master > > Details > ------- > https://git.postgresql.org/pg/commitdiff/a0bff38d133ac95fb56bbd868a128bba95ec46c9 > > Modified Files > -------------- > src/interfaces/ecpg/pgtypeslib/dt_common.c | 6 +- > .../ecpg/test/expected/pgtypeslib-dt_test.c | 76 +++++++++++++++------- > .../ecpg/test/expected/pgtypeslib-dt_test.stderr | 42 ++++++------ > .../ecpg/test/expected/pgtypeslib-dt_test.stdout | 3 +- > src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc | 30 +++++++++ > 5 files changed, 109 insertions(+), 48 deletions(-) > -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com When a patient asks the doctor, "Am I going to die?", he means "Am I going to die soon?"