Skip to content

Commit

Permalink
common: ofi_ifname_toaddr check ifa->ifa_addr for null
Browse files Browse the repository at this point in the history
ifa->ifa_addr might be NULL, thus led to crash.
  • Loading branch information
SiarheiVolkau authored Jan 3, 2025
1 parent 1e3cca6 commit e2be37f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,9 @@ static int ofi_ifname_toaddr(const char *name, uint32_t *addr_format,
return ret;

for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr->sa_family != AF_INET &&
ifa->ifa_addr->sa_family != AF_INET6)
if (ifa->ifa_addr == NULL ||
(ifa->ifa_addr->sa_family != AF_INET &&
ifa->ifa_addr->sa_family != AF_INET6))
continue;
if (!strcmp(name, ifa->ifa_name))
break;
Expand Down

0 comments on commit e2be37f

Please sign in to comment.