From: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
---|---|
To: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Fix possible dereference null pointer (PQprint) |
Date: | 2024-06-02 21:06:56 |
Message-ID: | CAEudQAqnJD+KLeD0WyCMpuPLWMgt9bpRFhAfiJWshxwdXyNVUQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Em sex., 31 de mai. de 2024 às 05:03, Daniel Gustafsson <daniel(at)yesql(dot)se>
escreveu:
> > On 27 May 2024, at 16:52, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
>
> > In the function *PQprint*, the variable po->fieldName can be NULL.
>
> Yes.
>
> > See the checks a few lines up.
>
> Indeed, let's check it.
>
> for (numFieldName = 0;
> po->fieldName && po->fieldName[numFieldName];
> numFieldName++)
> ;
> for (j = 0; j < nFields; j++)
> {
> int len;
> const char *s = (j < numFieldName && po->fieldName[j][0]) ?
> po->fieldName[j] : PQfname(res, j);
>
> If po->fieldName is NULL then numFieldName won't be incremented and will
> remain
> zero. In the check you reference we check (j < numFieldName) which will
> check
> the j in the range 0..nFields for being less than zero. The code thus does
> seem quite correct to me.
>
You are completely correct. My bad.
Thank you Daniel.
best regards,
Ranier Vilela
From | Date | Subject | |
---|---|---|---|
Next Message | Ranier Vilela | 2024-06-02 21:14:33 | Re: Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c) |
Previous Message | Erik Wienhold | 2024-06-02 20:44:25 | Re: pltcl crashes due to a syntax error |