From 4528215c99bace1980218a5df3d2fe11dbe9628d Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Wed, 11 Dec 2019 20:42:36 +0100 Subject: [PATCH] netif_find: check if atoi means '0' or error Since atoi() returns 0 on error, we need to check if name[2] is '0'. If it's not, atoi() failed. --- src/core/netif.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/netif.c b/src/core/netif.c index 2dd53d23..1cc28ce3 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -1744,6 +1744,10 @@ netif_find(const char *name) } num = (u8_t)atoi(&name[2]); + if (!num && (name[2] != 0)) { + /* this means atoi has failed */ + return NULL; + } NETIF_FOREACH(netif) { if (num == netif->num &&