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 1pRGXp-000052-NX for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Feb 2023 17:53:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pRGXo-0005d5-BE for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Feb 2023 17:53:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRGXo-0005cu-2h for pgsql-bugs@lists.postgresql.org; Sun, 12 Feb 2023 17:53:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRGXl-0007Cq-Sc for pgsql-bugs@lists.postgresql.org; Sun, 12 Feb 2023 17:53:43 +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 31CHrd2w907586; Sun, 12 Feb 2023 12:53:39 -0500 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17788: Incorrect memory access when parsing empty string as sql_standard interval In-reply-to: <17788-dabac9f98f7eafd5@postgresql.org> References: <17788-dabac9f98f7eafd5@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sun, 12 Feb 2023 10:00:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <907584.1676224419.1@sss.pgh.pa.us> Date: Sun, 12 Feb 2023 12:53:39 -0500 Message-ID: <907585.1676224419@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > When executing under valgrind: > SET IntervalStyle TO sql_standard; > SELECT ''::interval; > The following error is detected: > ==00:00:00:03.574 1155861== Use of uninitialised value of size 8 > ==00:00:00:03.574 1155861== at 0x606ADE: DecodeInterval > (datetime.c:3368) Good catch! For me, it dumps core about half the time even without using valgrind. > This defect was introduced by the commit e39f9904. > Before that commit the check > if (IntervalStyle == INTSTYLE_SQL_STANDARD && *field[0] == '-') > was guarded by > if (fmask == 0) > return DTERR_BAD_FORMAT; > but now field[0] is accessed unconditionally (even when nf == 0) for the > SQL_STANDARD style. Right. Not checking nf > 0 wasn't great style there in any case, but it accidentally failed to fail before. Fix pushed --- thanks for the report! regards, tom lane