pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Piotr Stefaniak <postgres@piotr-stefaniak.me>
Cc: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-committers@postgresql.org <pgsql-committers@postgresql.org>
Subject: Re: pgsql: Fix several one-byte buffer over-reads in to_number
Date: Tue, 09 Aug 2016 11:04:34 -0400
Message-ID: <23899.1470755074@sss.pgh.pa.us> (raw)
In-Reply-To: <AM4PR03MB1586B4F599626360E097A2B4F21B0@AM4PR03MB1586.eurprd03.prod.outlook.com>
References: <E1bWmJV-00083U-Gm@gemulon.postgresql.org>
	<AM4PR03MB1586B4F599626360E097A2B4F21B0@AM4PR03MB1586.eurprd03.prod.outlook.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Piotr Stefaniak <postgres@piotr-stefaniak.me> writes:
> I've been meaning to update my patch like this, but didn't want to 
> bother you before trying to find more issues with formatting.c (still 
> haven't found the time for that, sadly):

> -       if (*Np->inout_p == ' ')
> +       while (!OVERLOAD_TEST && isspace((unsigned char) *Np->inout_p))
>                  Np->inout_p++;

Meh.  I agree that replacing the "== ' '" test with isspace() would be
an improvement, since that seems to be the way it's done elsewhere in
formatting.c.  But changing this into a loop, so that it's willing to
consume any amount of whitespace, is a nontrivial change in the
specification of to_number().  I'm not at all sure it's a good idea;
IMO the point of to_number() is to parse numbers according to a fairly
tightly controlled format.

I'd even argue that unconditionally consuming a single space is the wrong
thing here.  Rather, I think what this is meant to be doing is treating a
space as one of the possible alternatives for a sign character, and so
instead of this what the code ought to be is an alternative on the same
footing as '+' or '-', a few lines down:

			else if (*Np->inout_p == '+')
			{
				*Np->number = '+';		/* set + */
				Np->inout_p++;
			}
+			else if (isspace((unsigned char) *Np->inout_p))
+			{
+				*Np->number = '+';		/* set + */
+				Np->inout_p++;
+			}
		}
	}


			regards, tom lane


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



view thread (8+ messages)

Message-ID: <23899.1470755074@sss.pgh.pa.us>
Permalink:  ../23899.1470755074@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23899.1470755074@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, postgres@piotr-stefaniak.me, peter_e@gmx.net
  Subject: Re: pgsql: Fix several one-byte buffer over-reads in to_number
  In-Reply-To: <23899.1470755074@sss.pgh.pa.us>
  References: <E1bWmJV-00083U-Gm@gemulon.postgresql.org> <AM4PR03MB1586B4F599626360E097A2B4F21B0@AM4PR03MB1586.eurprd03.prod.outlook.com> <23899.1470755074@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