Skip to content

Commit

Permalink
Problem: ziflist crashes on aliased iface (#2270)
Browse files Browse the repository at this point in the history
* Problem: ziflist crashes on aliased iface

Solution: NULL-check the `mac` variable before using it

---------

Co-authored-by: Mathieu SOUM <soum@ingenuity.io>
  • Loading branch information
Mathsoum and Mathieu SOUM committed Jul 19, 2023
1 parent 904c171 commit d26ea1a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ziflist.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,13 @@ s_reload (ziflist_t *self, bool ipv6)
ipv6 && (interface->ifa_addr->sa_family == AF_INET6)))
{
const char *mac = zhash_lookup(mactable, interface->ifa_name);
interface_t *item = s_interface_new (interface->ifa_name,
interface->ifa_addr, interface->ifa_netmask,
interface->ifa_broadaddr, mac);
if (item)
zlistx_add_end (list, item);
if (mac) {
interface_t *item = s_interface_new (interface->ifa_name,
interface->ifa_addr, interface->ifa_netmask,
interface->ifa_broadaddr, mac);
if (item)
zlistx_add_end (list, item);
}
}
interface = interface->ifa_next;
}
Expand Down

0 comments on commit d26ea1a

Please sign in to comment.