Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c) - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Date
Msg-id 7AD0FC93-18BB-44B1-894E-92B688124CD3@yesql.se
Whole thread Raw
In response to Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
List pgsql-hackers
> On 27 Jun 2024, at 13:50, Ranier Vilela <ranier.vf@gmail.com> wrote:

> Now with file patch really attached.

-    if (strlen(backupidstr) > MAXPGPATH)
+    if (strlcpy(state->name, backupidstr, sizeof(state->name)) >= sizeof(state->name))
         ereport(ERROR,

Stylistic nit perhaps, I would keep the strlen check here and just replace the
memcpy with strlcpy.  Using strlen in the error message check makes the code
more readable.


-    char        name[MAXPGPATH + 1];
+    char        name[MAXPGPATH];/* backup label name */

With the introduced use of strlcpy, why do we need to change this field?

--
Daniel Gustafsson




pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Add memory context type to pg_backend_memory_contexts view
Next
From: Bertrand Drouvot
Date:
Subject: Re: Avoid orphaned objects dependencies, take 3