mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 05:04:09 +08:00
hns: use strscpy() to instead of strncpy()
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@zte.com.cn> Signed-off-by: Yang Yang <yang.yang29@zte.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6d534ee057
commit
94d30e8933
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user