pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
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
Date: Sun, 12 Feb 2023 12:53:39 -0500
Message-ID: <907585.1676224419@sss.pgh.pa.us> (raw)
In-Reply-To: <17788-dabac9f98f7eafd5@postgresql.org>
References: <17788-dabac9f98f7eafd5@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> 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





view thread (2+ messages)

Message-ID: <907585.1676224419@sss.pgh.pa.us>
Permalink:  ../907585.1676224419@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/907585.1676224419@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17788: Incorrect memory access when parsing empty string as sql_standard interval
  In-Reply-To: <907585.1676224419@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox