提交 80a464d8 编写于 作者: X Xu Panda 提交者: 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: NXu Panda <xu.panda@zte.com.cn>
Signed-off-by: NYang Yang <yang.yang29@zte.com>
Reviewed-by: NJiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/202212091538591375035@zte.com.cnSigned-off-by: NJakub Kicinski <kuba@kernel.org>
上级 da05cecc
...@@ -639,13 +639,11 @@ static void hns3_get_drvinfo(struct net_device *netdev, ...@@ -639,13 +639,11 @@ static void hns3_get_drvinfo(struct net_device *netdev,
return; return;
} }
strncpy(drvinfo->driver, dev_driver_string(&h->pdev->dev), strscpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
sizeof(drvinfo->driver)); 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)); sizeof(drvinfo->bus_info));
drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0';
fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h); fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册