From 2f8886794ffd65029693c95dc445a9e696363922 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 e95cb672..595fc58c 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -1714,6 +1714,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 &&