[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D17491F2B@AcuExch.aculab.com>
Date: Mon, 15 Sep 2014 08:28:26 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Rickard Strandqvist' <rickard_strandqvist@...ctrumdigital.se>,
"Wolfgang Grandegger" <wg@...ndegger.com>,
Marc Kleine-Budde <mkl@...gutronix.de>
CC: Oliver Hartkopp <socketcan@...tkopp.net>,
Stephane Grosjean <s.grosjean@...k-system.com>,
Alexey Khoroshilov <khoroshilov@...ras.ru>,
"Christopher R. Baker" <cbaker@....ri.cmu.edu>,
"linux-can@...r.kernel.org" <linux-can@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] net: can: usb: peak_usb: pcan_usb_core.c: Cleaning up
missing null-terminate in conjunction with strncpy
From: Rickard Strandqvist
...
> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
...
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> index 644e6ab..d4fe8ac 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> @@ -830,7 +830,7 @@ static void peak_usb_disconnect(struct usb_interface *intf)
> char name[IFNAMSIZ];
>
> dev->state &= ~PCAN_USB_STATE_CONNECTED;
> - strncpy(name, netdev->name, IFNAMSIZ);
> + strlcpy(name, netdev->name, IFNAMSIZ);
>
> unregister_netdev(netdev);
> free_candev(netdev);
Or:
char name[sizeof netdev->name];
memcpy(name, netdev->name, sizeof netdev->name);
David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists