pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: boatcoder@gmail.com, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14859: Config file parsing is allergic to spaces on last line of file
Date: Tue, 17 Oct 2017 11:28:29 -0400
Message-ID: <17375.1508254109@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbMWwgmaEnBN3oacvUZ8iSBs4w4DuuRrd_P6FRkAF30zQ@mail.gmail.com>
References: <20171017141814.8203.27280@wrigleys.postgresql.org>
	<15819.1508251457@sss.pgh.pa.us>
	<CAKFQuwbMWwgmaEnBN3oacvUZ8iSBs4w4DuuRrd_P6FRkAF30zQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tue, Oct 17, 2017 at 7:44 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Hmph.  I can reproduce this in 9.6 and earlier, but not in v10 or HEAD.
>> Apparently somebody fixed it by accident.  Looking ...

> ​Probably as a side-effect of:
> "​Add view pg_hba_file_rules to display the contents of pg_hba.conf"
> to v10 (you can probably find the commit hash faster than I).

Close, but apparently it was the adjacent commit 1e5a5d03d,
"Simplify some long-obsolete code in hba.c's next_token()."
in which I wrote

    Also, ensure that we don't return with *lineptr set to someplace past the
    terminating '\0'; that would be catastrophic if a caller were to ask for
    another token from the same line.  This is just latent since no callers
    actually do call again after a "false" return; but considering that it was
    actually costing us extra code to do it wrong, we might as well make it
    bulletproof.

I was wrong to think that the problem was only latent, because
tokenize_file() decides whether there's more on the line using

		while (strlen(lineptr) > 0)

so that having advanced lineptr past the current line's '\0' allows
it to see (and process) whatever had been in the buffer beyond that
from preceding line(s).

This seems to have been broken since 9.3; kinda surprising nobody
noticed earlier.  I shall go back-patch 1e5a5d03d --- it does a bit
more than the minimum needed to fix the bug, but the other changes
seem harmless enough.

			regards, tom lane


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



view thread (4+ messages)

Message-ID: <17375.1508254109@sss.pgh.pa.us>
Permalink:  ../17375.1508254109@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17375.1508254109@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, david.g.johnston@gmail.com
  Subject: Re: BUG #14859: Config file parsing is allergic to spaces on last line of file
  In-Reply-To: <17375.1508254109@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