public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Joseph Koshakow <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Fix overflow in DecodeInterval
Date: Sun, 03 Apr 2022 12:30:32 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAAvxfHdYRpNNDt==S67HNrx9USBTy=R3NCVqDopfxNifKT-mZQ@mail.gmail.com>
References: <CAAvxfHff0JLYHwyBrtMx_=6wr=k2Xp+D+-X3vEhHjJYMj+mQcg@mail.gmail.com>
	<[email protected]>
	<CAAvxfHd-DZzRC9wROFbsZq=8zK+R-5G7DAoZ-oUK8n09cGA0eA@mail.gmail.com>
	<CAAvxfHddHqA=dDKrbi+d+vo52j=sUwVt6_PYOsJGo+Eq91v4=g@mail.gmail.com>
	<[email protected]>
	<CAAvxfHdrQc8pVoSnTPBfTKzHQzmYTg1qheNxMLoWDcrWpTJapg@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAAvxfHd3gsOkGsbu5AVG+ayHiqsWzuZsi8WknL7v4C_A_4TwOQ@mail.gmail.com>
	<CAAvxfHeNNjsJarnzVOycP__T2x4iwbbSWBDaDePcuBjz8--x6Q@mail.gmail.com>
	<[email protected]>
	<CAAvxfHfKYHw8n19s7eAcDo_B2T1SS22O1p0X4OE5_WBK230O+Q@mail.gmail.com>
	<CAAvxfHduBhZdUXLFwLOSGW=0c17frLojcbCqNsZrw5n73pekZg@mail.gmail.com>
	<CAAvxfHdVaHrriTWyvsLg3POX13rOyUGysur59sOT02qmmTq0Rg@mail.gmail.com>
	<[email protected]>
	<CAAvxfHdQGiX2xC78y3Y_LTdCiTOWtMXkaLai7s7-mG+=H7qNXA@mail.gmail.com>
	<CAAvxfHd730o24gGhu5YoL1Sxt! [email protected]>
	<CAAvxfHdM_8rhBP+GLj_9rSHswjBESztrxEV+GrTvXv9fAnBUfQ@mail.gmail.com>
	<CAAvxfHecFFqpn=5H0T3N1Bki=rkgW0BmRNOZ1NZdKDMCOoy+Rw@mail.gmail.com>
	<[email protected]>
	<CAAvxfHf8mXDaCjHmvDHNcKw8o8+cBOHiB+nE5ea9_a-1oiVS0Q@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAAvxfHcKD3FGw6AseTLqMtwoY4a=rmCR6AXQ997Av611yrSbrA@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAAvxfHdYRpNNDt==S67HNrx9USBTy=R3NCVqDopfxNifKT-mZQ@mail.gmail.com>

Joseph Koshakow <[email protected]> writes:
> On Sun, Apr 3, 2022 at 12:03 PM Tom Lane <[email protected]> wrote:
>> Oh ... a bit of testing says that strtod() on an empty string
>> succeeds (returning zero) on Linux, but fails with EINVAL on
>> AIX.  The latter is a lot less surprising than the former,
>> so we'd better cope.

> I'm not sure I follow exactly. Where would we pass an empty
> string to strtod()? Wouldn't we be passing a string with a
> single character of '.'?

Oh, I was thinking that we passed "cp + 1" to strtod, but that
was just caffeine deprivation.  You're right, what we are asking
it to parse is "." not "".  The result is the same though:
per testing, AIX sets EINVAL and Linux doesn't.

> So I think we need to check that endptr has moved both after
> the call to strtoi64() and strtod().

I'm not sure we need to do that explicitly, given that there's
a check later as to whether endptr is pointing at \0; that will
fail if endptr wasn't advanced.

The fix I was loosely envisioning was to check for cp[1] == '\0'
and not bother calling strtod() in that case.

			regards, tom lane






view thread (20+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Fix overflow in DecodeInterval
  In-Reply-To: <[email protected]>

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

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