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

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
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:34:45
Message-ID: CAEudQAoED8DCDxfpGmZzjw+jCEd+0aTvCf=cComZsRjENW05HQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em dom., 23 de jun. de 2024 às 21:24, Michael Paquier <michael(at)paquier(dot)xyz>
escreveu:

> On Sun, Jun 23, 2024 at 09:08:47PM -0300, Fabrízio de Royes Mello wrote:
> > Doesn’t “sizeof” solve the problem? It take in account the
> null-termination
> > character.
>
> The size of BackupState->name is fixed with MAXPGPATH + 1, so it would
> be a better practice to use strlcpy() with sizeof(name) anyway?
>
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.

best regards,
Ranier Vilela

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-06-24 00:53:52 Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Previous Message Michael Paquier 2024-06-24 00:34:05 Re: replace strtok()