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.
This commit is contained in:
Simon Goldschmidt 2019-12-11 20:42:36 +01:00
parent 02ab8c91a9
commit 2f8886794f

View File

@ -1714,6 +1714,10 @@ netif_find(const char *name)
} }
num = (u8_t)atoi(&name[2]); num = (u8_t)atoi(&name[2]);
if (!num && (name[2] != 0)) {
/* this means atoi has failed */
return NULL;
}
NETIF_FOREACH(netif) { NETIF_FOREACH(netif) {
if (num == netif->num && if (num == netif->num &&