Commit 80a464d8 authored by Xu Panda's avatar Xu Panda Committed by Jakub Kicinski

net: hns3: 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: default avatarXu Panda <xu.panda@zte.com.cn>
Signed-off-by: default avatarYang Yang <yang.yang29@zte.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/202212091538591375035@zte.com.cnSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent da05cecc
......@@ -639,13 +639,11 @@ static void hns3_get_drvinfo(struct net_device *netdev,
return;
}
strncpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
strscpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
sizeof(drvinfo->driver));
drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';
strncpy(drvinfo->bus_info, pci_name(h->pdev),
strscpy(drvinfo->bus_info, pci_name(h->pdev),
sizeof(drvinfo->bus_info));
drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0';
fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment