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: Xu Panda <xu.panda@zte.com.cn> Signed-off-by: Yang Yang <yang.yang29@zte.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Link: https://lore.kernel.org/r/202212091538591375035@zte.com.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
da05cecc49
commit
80a464d83f
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue