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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 8 Dec 2022 14:18:06 +0100
From:   Michal Kubecek <mkubecek@...e.cz>
To:     yang.yang29@....com.cn
Cc:     salil.mehta@...wei.com, yisen.zhuang@...wei.com,
        davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com, brianvv@...gle.com, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, xu.panda@....com.cn
Subject: Re: [PATCH linux-next] ethtool: use strscpy() to instead of strncpy()

On Thu, Dec 08, 2022 at 07:47:41PM +0800, yang.yang29@....com.cn wrote:
> From: Xu Panda <xu.panda@....com.cn>
> 
> The implementation of strscpy() is more robust and safer.
> That's now the recommended way to copy NUL terminated strings.
> 
> Signed-off-by: Xu Panda <xu.panda@....com.cn>
> Signed-off-by: Yang Yang <yang.yang29@....com>

The patch looks good to me but the subject prefix should rather be
"hns:" to reflect its target code.

Michal

> ---
>  drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> index 54faf0f2d1d8..b54f3706fb97 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> @@ -644,18 +644,15 @@ 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,
> +	strscpy(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';
> +	strscpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver));
> 
> -	strncpy(drvinfo->bus_info, priv->dev->bus->name,
> +	strscpy(drvinfo->bus_info, priv->dev->bus->name,
>  		sizeof(drvinfo->bus_info));
> -	drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0';
> 
> -	strncpy(drvinfo->fw_version, "N/A", ETHTOOL_FWVERS_LEN);
> +	strscpy(drvinfo->fw_version, "N/A", ETHTOOL_FWVERS_LEN);
>  	drvinfo->eedump_len = 0;
>  }
> 
> -- 
> 2.15.2

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ