From nobody Wed Jul 1 13:26:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12F53C433FE for ; Tue, 21 Dec 2021 07:12:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234771AbhLUHMh (ORCPT ); Tue, 21 Dec 2021 02:12:37 -0500 Received: from smtpbg128.qq.com ([106.55.201.39]:37749 "EHLO smtpbg587.qq.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234743AbhLUHMg (ORCPT ); Tue, 21 Dec 2021 02:12:36 -0500 X-QQ-mid: bizesmtp39t1640070724tej8l5fr Received: from localhost.localdomain (unknown [118.121.67.96]) by esmtp6.qq.com (ESMTP) with id ; Tue, 21 Dec 2021 15:12:02 +0800 (CST) X-QQ-SSF: 01000000002000D0K000B00A0000000 X-QQ-FEAT: 3u0oYPVhaeMuRPB0Xqzd/w4o3OO6lXBAlWAfvA8AcdvTZYMUBeN15dLIO8TVW CuGhu0G1cGgkn+EqmhBgPksUThch5I4JXj3y1efVCSfJcTQWdduS7mGN/jPCfl8hFFdTwQE Qq1HGg60X9IjS5LYWnMREdZ2Fs6oaPLph0AerfiI2DS3YYf3oMX2wIUwsghVgZ1cpj9Afz5 N1YC2Y3j94j/uKo/4XsD6AotfR4JMjIozqowoi/Yh084c12q9+0lEL0x3UU+2jvJLttEVB5 xrHxLm9R6pLHfGmb6KVgSglsUAZ1qQcKTsU1/aNJW8GECEI/b4mB42gZ9S6A4G1xFF0jWxk XgbFxVNajroxwKJFqNeG1yOzG0PJta9c8SzJw9zM0ubw2GOaOEQ8yBukOxLZA== X-QQ-GoodBg: 0 From: Jason Wang To: davem@davemloft.net Cc: chessman@tux.org, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Wang Subject: [PATCH] net: tlan: replace strlcpy with strscpy Date: Tue, 21 Dec 2021 15:11:54 +0800 Message-Id: <20211221071154.729300-1-wangborong@cdjrlc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:cdjrlc.com:qybgspam:qybgspam5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The strlcpy should not be used because it doesn't limit the source length. So that it will lead some potential bugs. But the strscpy doesn't require reading memory from the src string beyond the specified "count" bytes, and since the return value is easier to error-check than strlcpy()'s. In addition, the implementation is robust to the string changing out from underneath it, unlike the current strlcpy() implementation. Thus, replace strlcpy with strscpy. Signed-off-by: Jason Wang --- drivers/net/ethernet/ti/tlan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c index 741c42c6a417..b3da76efa8f5 100644 --- a/drivers/net/ethernet/ti/tlan.c +++ b/drivers/net/ethernet/ti/tlan.c @@ -762,12 +762,12 @@ static void tlan_get_drvinfo(struct net_device *dev, { struct tlan_priv *priv =3D netdev_priv(dev); =20 - strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); + strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); if (priv->pci_dev) - strlcpy(info->bus_info, pci_name(priv->pci_dev), + strscpy(info->bus_info, pci_name(priv->pci_dev), sizeof(info->bus_info)); else - strlcpy(info->bus_info, "EISA", sizeof(info->bus_info)); + strscpy(info->bus_info, "EISA", sizeof(info->bus_info)); } =20 static int tlan_get_eeprom_len(struct net_device *dev) --=20 2.34.1