[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5dfe389482c54437873d4c0ae29eca8a@AcuMS.aculab.com>
Date: Fri, 2 Mar 2018 10:51:33 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Florian Fainelli' <f.fainelli@...il.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...oirfairelinux.com>,
Woojung Huh <Woojung.Huh@...rochip.com>,
Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
open list <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH net 3/4] net: dsa: microchip: Utilize strncpy() for
ethtool::get_strings
From: Florian Fainelli
>
> Do not use memcpy() which is not safe, but instead use strncpy() which
> will make sure that the string is NUL terminated (in the Linux
> implementation) if the string is smaller than the length specified. This
> fixes KASAN out of bounds warnings while fetching port statistics.
You really ought to use a copy function that will truncate the
string if it is too long.
Just assuming the string isn't too long is asking for trouble.
You might (almost) just use strcpy().
strlcpy() will probably work best here.
David
Powered by blists - more mailing lists