Re: pgindent (was Re: [COMMITTERS] pgsql: Preventive maintenance in advance of pgindent run.)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgindent (was Re: [COMMITTERS] pgsql: Preventive maintenance in advance of pgindent run.)
Date: 2017-05-21 01:00:15
Message-ID: 322.1495328415@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

I wrote:
> Also, I found two places where an overlength comment line is simply busted
> altogether --- notice that a character is missing at the split point:

I found the cause of that: you need to apply this patch:

--- freebsd_indent/pr_comment.c~ 2017-05-17 14:59:31.548442801 -0400
+++ freebsd_indent/pr_comment.c 2017-05-20 20:51:16.447332977 -0400
@@ -344,8 +353,8 @@ pr_comment(void)
{
int len = strlen(t_ptr);

- CHECK_SIZE_COM(len);
- memmove(e_com, t_ptr, len);
+ CHECK_SIZE_COM(len + 1);
+ memmove(e_com, t_ptr, len + 1);
last_bl = strpbrk(e_com, " \t");
e_com += len;
}

As the code stands, the strpbrk call is being applied to a
not-null-terminated string and therefore is sometimes producing an
insane value of last_bl, messing up decisions later in the comment.
Having the memmove include the trailing \0 resolves that.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-05-21 01:51:15 pgsql: Change documentation references to PG website to use https: not
Previous Message Tom Lane 2017-05-19 22:05:27 pgsql: Rethink flex flags for syncrep_scanner.l.

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2017-05-21 03:41:29 Re: bumping HASH_VERSION to 3
Previous Message Bruce Momjian 2017-05-20 23:56:32 Re: bumping HASH_VERSION to 3