Skip to content

Commit 80a464d

Browse files
Xu Pandakuba-moo
authored andcommitted
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 <[email protected]> Signed-off-by: Yang Yang <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent da05cec commit 80a464d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,11 @@ static void hns3_get_drvinfo(struct net_device *netdev,
639639
return;
640640
}
641641

642-
strncpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
642+
strscpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
643643
sizeof(drvinfo->driver));
644-
drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';
645644

646-
strncpy(drvinfo->bus_info, pci_name(h->pdev),
645+
strscpy(drvinfo->bus_info, pci_name(h->pdev),
647646
sizeof(drvinfo->bus_info));
648-
drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0';
649647

650648
fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h);
651649

0 commit comments

Comments
 (0)