Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Date: 2024-06-24 00:53:52
Message-ID: ZnjDoP_MZQefJfwJ@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jun 23, 2024 at 09:34:45PM -0300, Ranier Vilela wrote:
> It's not critical code, so I think it's ok to use strlen, even because the
> result of strlen will already be available using modern compilers.
>
> So, I think it's ok to use memcpy with strlen + 1.

It seems to me that there is a pretty good argument to just use
strlcpy() for the same reason as the one you cite: this is not a
performance-critical code, and that's just safer.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2024-06-24 00:57:00 Proposal: Division operator for (interval / interval => double precision)
Previous Message Ranier Vilela 2024-06-24 00:34:45 Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)