Re: Some doubious code in pgstat.c

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Some doubious code in pgstat.c
Date: 2020-11-04 09:50:04
Message-ID: CAA4eK1JTdz_+DUYSKbJ-Uh12E66okj3sNCKLQE=d43Ymu-vciA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 4, 2020 at 2:25 PM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)com> wrote:
>
> Hello.
>
> While updating a patch, I noticed that the replication slot stats
> patch (9868167500) put some somewhat doubious codes.
>
> In pgstat_recv_replslot, an assertion like the following exists:
>
> > idx = pgstat_replslot_index(msg->m_slotname, !msg->m_drop);
> ..
> > Assert(idx >= 0 && idx < max_replication_slots);
>
> But the idx should be 0..(max_replication_slots - 1).
>

Right.

>
> In the same function the following code assumes that the given "char
> *name" has the length of NAMEDATALEN. It actually is, but that
> assumption seems a bit bogus. I think it should use strlcpy instead.
>

Agreed.

Your patch looks good to me.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-11-04 10:02:54 Re: [HACKERS] logical decoding of two-phase transactions
Previous Message Pavel Borisov 2020-11-04 09:43:18 Re: Bogus documentation for bogus geometric operators