Commit 21780f89 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jakub Kicinski

mac_pton: Don't access memory over expected length

The strlen() may go too far when estimating the length of
the given string. In some cases it may go over the boundary
and crash the system which is the case according to the commit
13a55372 ("ARM: orion5x: Revert commit 4904dbda.").

Rectify this by switching to strnlen() for the expected
maximum length of the string.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221108141108.62974-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 13bd8558
......@@ -6,10 +6,11 @@
bool mac_pton(const char *s, u8 *mac)
{
size_t maxlen = 3 * ETH_ALEN - 1;
int i;
/* XX:XX:XX:XX:XX:XX */
if (strlen(s) < 3 * ETH_ALEN - 1)
if (strnlen(s, maxlen) < maxlen)
return false;
/* Don't dirty result unless string is valid MAC. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment