From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Simplify some long-obsolete code in hba.c's next_token(). |
Date: | 2017-01-30 23:42:47 |
Message-ID: | E1cYLax-00066X-5e@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Simplify some long-obsolete code in hba.c's next_token().
next_token() oddly set its buffer space consumption limit to one before
the last char position in the buffer, not the last as you'd expect.
The reason is there was once an ugly kluge to mark keywords by appending
a newline to them, potentially requiring one more byte. Commit e5e2fc842
removed that kluge, but failed to notice that the length limit could be
increased.
Also, remove some vestigial handling of newline characters in the buffer.
That was left over from when this function read the file directly using
getc(). Commit 7f49a67f9 changed it to read from a buffer, from which
tokenize_file had already removed the only possible occurrence of newline,
but did not simplify this function in consequence.
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.
Noted while reviewing pg_hba_file_rules patch.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/1e5a5d03da14ba9b734c6a2a1a822dcd8af110eb
Modified Files
--------------
src/backend/libpq/hba.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2017-01-31 16:18:28 | pgsql: test_pg_dump: perltidy cleanup |
Previous Message | Tom Lane | 2017-01-30 23:00:34 | pgsql: Invent pg_hba_file_rules view to show the content of pg_hba.conf |