public inbox for [email protected]  
help / color / mirror / Atom feed
From: Daniel Gustafsson <[email protected]>
To: Ranier Vilela <[email protected]>
Cc: Yugo NAGATA <[email protected]>
Cc: Richard Guo <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Date: Mon, 1 Jul 2024 11:20:19 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAEudQArkgfqHOCwJ=SNvOHC_esELM=71hwE0YmzELpZ_Bbu9bQ@mail.gmail.com>
References: <CAEudQApAsbLsQ+gGiw-hT+JwGhgogFa_=5NUkgFO6kOPxyNidQ@mail.gmail.com>
	<CAMbWs4-f4D425C73p0WPBYb2qpiGZyJGvivxS15rEz_igR8vMQ@mail.gmail.com>
	<CAEudQArgZA3pnrAtG15wDUcW_hLLPv69otLBaiTak9nLZr7MOg@mail.gmail.com.sranhm>
	<[email protected]>
	<CAEudQAqkDPpQDOnAg_21w5_Sz8Z7jomPHsP-nqajo_=WoUKCzw@mail.gmail.com>
	<CAEudQArkgfqHOCwJ=SNvOHC_esELM=71hwE0YmzELpZ_Bbu9bQ@mail.gmail.com>

> On 27 Jun 2024, at 13:50, Ranier Vilela <[email protected]> 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







view thread (10+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox