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 1sODGI-00D2TV-B9 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 09:23:50 +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 1sODGG-00HZXq-77 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 09:23:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sODD7-00HVIW-6K for pgsql-hackers@lists.postgresql.org; Mon, 01 Jul 2024 09:20:33 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sODD5-004SZP-He for pgsql-hackers@postgresql.org; Mon, 01 Jul 2024 09:20:32 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 1431D3021C7F for ; Mon, 01 Jul 2024 11:20:31 +0200 (CEST) Received: from s980.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id 046EF2E28A2A; Mon, 01 Jul 2024 11:20:31 +0200 (CEST) Received: from s471.loopia.se (unknown [172.22.191.5]) by s980.loopia.se (Postfix) with ESMTP id 020AE2201654; Mon, 01 Jul 2024 11:20:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1.2 X-Spam-Level: X-Spam-Status: No, score=-1.2 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1] autolearn=disabled Authentication-Results: s471.loopia.se (amavisd-new); dkim=pass (2048-bit key) header.d=yesql.se Received: from s981.loopia.se ([172.22.191.5]) by s471.loopia.se (s471.loopia.se [172.22.190.35]) (amavisd-new, port 10024) with UTF8LMTP id e6y01Hv_jSfe; Mon, 1 Jul 2024 11:20:30 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s981.loopia.se (Postfix) with ESMTPSA id 7C96A22B173E; Mon, 01 Jul 2024 11:20:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yesql.se; s=loopiadkim1707475645; t=1719825630; bh=Bne+F6RfEEbLAeyownd4QAflKkz7NqEIC3Sc2phkpz4=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=OpZF9Zn95DzKGSDb8CmNfXRl5bkZxjShfi+Bx5XpoNIGbSPJ/XA8lHyWOaKwIBD+v Ylj1VTdGxh0O8BCpqVPHkNMdgMYnVuHFD9cD7JrwY616BTsSOvVE026iMgHjdfMjzL igNCkDMbZ7EuxBnT9uPpWChdpNFdUb8sYgEvQTBnPqyKeVe3Q9NJyzqYa3LvzgfSba pyPE7pKdyAWcowpPcKTIImDMC16K5/5ocOkwTXxX+2FPcJH4+vAuyAwkQ3G0jnYDiu axUD0ikBHLpzp/TMGtqqO16pd43GpqwZilahWgbLId0tVmBEvzgsaeNehHHD1ioutn KporWoJcRrRWg== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c) From: Daniel Gustafsson In-Reply-To: Date: Mon, 1 Jul 2024 11:20:19 +0200 Cc: Yugo NAGATA , Richard Guo , PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: <7AD0FC93-18BB-44B1-894E-92B688124CD3@yesql.se> References: <20240627130108.7a4b4217b31472cd22161918@sranhm.sraoss.co.jp> To: Ranier Vilela X-Mailer: Apple Mail (2.3774.600.62) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 27 Jun 2024, at 13:50, Ranier Vilela wrote: > Now with file patch really attached. - if (strlen(backupidstr) > MAXPGPATH) + if (strlcpy(state->name, backupidstr, sizeof(state->name)) >=3D = 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