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

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp>, Richard Guo <guofenglinux(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Date: 2024-07-01 09:20:19
Message-ID: 7AD0FC93-18BB-44B1-894E-92B688124CD3@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 27 Jun 2024, at 13:50, Ranier Vilela <ranier(dot)vf(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-07-01 09:39:17 Re: Avoid orphaned objects dependencies, take 3
Previous Message David Rowley 2024-07-01 09:20:18 Re: Add memory context type to pg_backend_memory_contexts view