lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 13 Jul 2018 03:25:39 +0200 From: Dominique Martinet <asmadeus@...ewreck.org> To: unlisted-recipients:; (no To-header on input) Cc: Dominique Martinet <asmadeus@...ewreck.org>, Yisen Zhuang <yisen.zhuang@...wei.com>, Salil Mehta <salil.mehta@...wei.com>, "David S. Miller" <davem@...emloft.net>, Matthias Brugger <matthias.bgg@...il.com>, Lin Yun Sheng <linyunsheng@...wei.com>, stephen hemminger <stephen@...workplumber.org>, netdev@...r.kernel.org, linux-kernel@...r.kernel.org Subject: [PATCH 07/18] hisilicon: change strncpy+truncation to strlcpy Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet <asmadeus@...ewreck.org> --- Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the first patch of the serie) for the motivation behind this patch drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 7 ++----- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c index 2e14a3ae1d8b..35b4d72d1997 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c @@ -638,12 +638,9 @@ static void hns_nic_get_drvinfo(struct net_device *net_dev, { struct hns_nic_priv *priv = netdev_priv(net_dev); - strncpy(drvinfo->version, HNAE_DRIVER_VERSION, + strlcpy(drvinfo->version, HNAE_DRIVER_VERSION, sizeof(drvinfo->version)); - drvinfo->version[sizeof(drvinfo->version) - 1] = '\0'; - - strncpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver)); - drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; + strlcpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver)); strncpy(drvinfo->bus_info, priv->dev->bus->name, sizeof(drvinfo->bus_info)); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 40c0425b4023..630c8d186707 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -493,13 +493,10 @@ static void hns3_get_drvinfo(struct net_device *netdev, struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = priv->ae_handle; - strncpy(drvinfo->version, hns3_driver_version, + strlcpy(drvinfo->version, hns3_driver_version, sizeof(drvinfo->version)); - drvinfo->version[sizeof(drvinfo->version) - 1] = '\0'; - - strncpy(drvinfo->driver, h->pdev->driver->name, + strlcpy(drvinfo->driver, h->pdev->driver->name, sizeof(drvinfo->driver)); - drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; strncpy(drvinfo->bus_info, pci_name(h->pdev), sizeof(drvinfo->bus_info)); -- 2.17.1
Powered by blists - more mailing lists