diff options
| author | Paul Jakma <paul@quagga.net> | 2009-08-06 12:08:50 +0100 | 
|---|---|---|
| committer | Paul Jakma <paul@quagga.net> | 2009-08-28 14:51:18 +0100 | 
| commit | 3e4ee9591aa2d84f01ae478afd273ac55add0a1c (patch) | |
| tree | dda1a647bc59031728ac28733feec89d8a38a8b2 /lib/if.c | |
| parent | 27f5dc8120e1c6902e29d86cf0d77b82cf3848c0 (diff) | |
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
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 16 | 
1 files changed, 9 insertions, 7 deletions
| @@ -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;  } | 
