Skip to content

Commit 493c3ca

Browse files
Len Bakerdavem330
authored andcommitted
drivers/net/usb: Remove all strcpy() uses
strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). Signed-off-by: Len Baker <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9c638ea commit 493c3ca

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

drivers/net/usb/ipheth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ static int ipheth_probe(struct usb_interface *intf,
443443

444444
netdev->netdev_ops = &ipheth_netdev_ops;
445445
netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;
446-
strcpy(netdev->name, "eth%d");
446+
strscpy(netdev->name, "eth%d", sizeof(netdev->name));
447447

448448
dev = netdev_priv(netdev);
449449
dev->udev = udev;

drivers/net/usb/usbnet.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
17251725
dev->interrupt_count = 0;
17261726

17271727
dev->net = net;
1728-
strcpy (net->name, "usb%d");
1728+
strscpy(net->name, "usb%d", sizeof(net->name));
17291729
memcpy (net->dev_addr, node_id, sizeof node_id);
17301730

17311731
/* rx and tx sides can use different message sizes;
@@ -1752,13 +1752,13 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
17521752
if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
17531753
((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||
17541754
(net->dev_addr [0] & 0x02) == 0))
1755-
strcpy (net->name, "eth%d");
1755+
strscpy(net->name, "eth%d", sizeof(net->name));
17561756
/* WLAN devices should always be named "wlan%d" */
17571757
if ((dev->driver_info->flags & FLAG_WLAN) != 0)
1758-
strcpy(net->name, "wlan%d");
1758+
strscpy(net->name, "wlan%d", sizeof(net->name));
17591759
/* WWAN devices should always be named "wwan%d" */
17601760
if ((dev->driver_info->flags & FLAG_WWAN) != 0)
1761-
strcpy(net->name, "wwan%d");
1761+
strscpy(net->name, "wwan%d", sizeof(net->name));
17621762

17631763
/* devices that cannot do ARP */
17641764
if ((dev->driver_info->flags & FLAG_NOARP) != 0)

0 commit comments

Comments
 (0)