Re: Fix possible bogus array out of bonds (src/backend/access/brin/brin_minmax_multi.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix possible bogus array out of bonds (src/backend/access/brin/brin_minmax_multi.c)
Date: 2022-09-14 00:34:51
Message-ID: CAEudQAr+roB_9LEyyeLVVvZ0fp2P6BDaCcyzxYoyUEnDrGdsLg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em seg., 5 de set. de 2022 às 23:02, David Rowley <dgrowleyml(at)gmail(dot)com>
escreveu:

> On Tue, 6 Sept 2022 at 13:52, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
> >
> > Em seg., 5 de set. de 2022 às 22:29, David Rowley <dgrowleyml(at)gmail(dot)com>
> escreveu:
> >> It feels like it would be good if we had a way to detect a few of
> >> these issues much earlier than we are currently. There's been a long
> >> series of commits fixing up this sort of thing. If we had a tool to
> >> parse the .c files and look for things like a function call to
> >> appendPQExpBuffer() and appendStringInfo() with only 2 parameters (i.e
> >> no va_arg arguments).
> >
> > StaticAssert could check va_arg no?
>
> I'm not sure exactly what you have in mind. If you think you have a
> way to make that work, it would be good to see a patch with it.
>
About this:

1. StaticAssertSmt can not help.
Although some posts on the web show that it is possible to calculate the
number of arguments,
I didn't get anything useful.
So I left this option.

2. Compiler supports
Best solution.
But currently does not allow the suggestion to use another function.

3. Owner tool
Temporary solution.
Can help, until the compilers build support for it.

So, I made one very simple tool, can do the basics here.
Not meant to be some universal lint.
It only processes previously coded functions.

pg_check test1.c
line (1): should be appendPQExpBufferStr?
line (2): should be appendPQExpBufferChar?
line (4): should be appendPQExpBufferStr?
line (5): should be appendPQExpBufferStr?

I don't think it's anywhere near the quality to be considered Postgres, but
it could be a start.
If it helps, great, if not, fine.

regards,
Ranier Vilela

Attachment Content-Type Size
pg_check.c text/plain 4.3 KB
test1.c text/plain 283 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2022-09-14 02:05:20 Re: pgsql: Fix perltidy breaking perlcritic
Previous Message Tom Lane 2022-09-13 23:47:38 Re: minimum perl version