[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211221071426.733023-1-wangborong@cdjrlc.com>
Date: Tue, 21 Dec 2021 15:14:26 +0800
From: Jason Wang <wangborong@...rlc.com>
To: kuba@...nel.org
Cc: davem@...emloft.net, arnd@...db.de, wangborong@...rlc.com,
jgg@...pe.ca, netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] net: dl2k: replace strlcpy with strscpy
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 <wangborong@...rlc.com>
---
drivers/net/ethernet/dlink/dl2k.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index a301f7e6a440..2c67a857a42f 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -1235,8 +1235,8 @@ static void rio_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
{
struct netdev_private *np = netdev_priv(dev);
- strlcpy(info->driver, "dl2k", sizeof(info->driver));
- strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
+ strscpy(info->driver, "dl2k", sizeof(info->driver));
+ strscpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
}
static int rio_get_link_ksettings(struct net_device *dev,
--
2.34.1
Powered by blists - more mailing lists