Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sLaMn-00FW0H-JU for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Jun 2024 03:27:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sLaMk-003e7F-TA for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Jun 2024 03:27:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sLaMk-003e5k-J7 for pgsql-hackers@lists.postgresql.org; Mon, 24 Jun 2024 03:27:38 +0000 Received: from ml.sraoss.co.jp ([66.11.59.17]) by makus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sLaMc-002ou9-VY for pgsql-hackers@postgresql.org; Mon, 24 Jun 2024 03:27:36 +0000 Received: from sranhm.sraoss.co.jp (unknown [192.168.174.167]) by osspc26.sraoss.co.jp (Postfix) with ESMTP id AB61D2F000FC; Mon, 24 Jun 2024 12:27:28 +0900 (JST) Received: from yugon-CFSV7-1 (unknown [192.168.176.17]) by sranhm.sraoss.co.jp (Postfix) with SMTP id 7115C360A54; Mon, 24 Jun 2024 12:27:28 +0900 (JST) Date: Mon, 24 Jun 2024 12:27:28 +0900 From: Yugo NAGATA To: Ranier Vilela Cc: Michael Paquier , =?UTF-8?B?RmFicsOtemlv?= de Royes Mello , Pg Hackers Subject: Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c) Message-Id: <20240624122728.95d555f1358547a75abebd85@sranhm.sraoss.co.jp> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 23 Jun 2024 22:34:03 -0300 Ranier Vilela wrote: > Em dom., 23 de jun. de 2024 às 22:14, Ranier Vilela > escreveu: > > > Em dom., 23 de jun. de 2024 às 22:05, Ranier Vilela > > escreveu: > > > >> Em dom., 23 de jun. de 2024 às 21:54, Michael Paquier < > >> michael@paquier.xyz> escreveu: > >> > >>> 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. > >>> > >> Yeah, I'm fine with strlcpy. I'm not against it. > >> > > Perhaps, like the v2? > > > > Either v1 or v2, to me, looks good. > > > Thinking about, does not make sense the field size MAXPGPATH + 1. > all other similar fields are just MAXPGPATH. > > If we copy MAXPGPATH + 1, it will also be wrong. > So it is necessary to adjust logbackup.h as well. I am not sure whether we need to change the size of the field, but if change it, I wonder it is better to modify the following message from MAXPGPATH to MAXPGPATH -1. errmsg("backup label too long (max %d bytes)", MAXPGPATH))); Regards, Yugo Nagata > > So, I think that v3 is ok to fix. > > best regards, > Ranier Vilela > > > > > best regards, > > Ranier Vilela > > > >> -- Yugo NAGATA