mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 21:10:28 +00:00
lib: if_lookup_by_name should be more robust to null argument
* if.c: (if_lookup_by_name) shouldn't crash just cause we got a NULL name
This commit is contained in:
parent
27f5dc8120
commit
3e4ee9591a
16
lib/if.c
16
lib/if.c
@ -205,7 +205,8 @@ ifname2ifindex (const char *name)
|
||||
{
|
||||
struct interface *ifp;
|
||||
|
||||
return ((ifp = if_lookup_by_name(name)) != NULL) ? ifp->ifindex : 0;
|
||||
return ((ifp = if_lookup_by_name(name)) != NULL) ? ifp->ifindex
|
||||
: IFINDEX_INTERNAL;
|
||||
}
|
||||
|
||||
/* Interface existance check by interface name. */
|
||||
@ -214,12 +215,13 @@ if_lookup_by_name (const char *name)
|
||||
{
|
||||
struct listnode *node;
|
||||
struct interface *ifp;
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
|
||||
{
|
||||
if (strcmp(name, ifp->name) == 0)
|
||||
return ifp;
|
||||
}
|
||||
|
||||
if (name)
|
||||
for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
|
||||
{
|
||||
if (strcmp(name, ifp->name) == 0)
|
||||
return ifp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user