Check return value of if_indextoname().
This should fix issue
@@ -91,7 +91,7 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
int fd;
memset(&ifr, 0, sizeof(struct ifreq));
- if_indextoname(if_index, ifr.ifr_name);
+ if (if_indextoname(if_index, ifr.ifr_name) != NULL) {
/* TODO can I use the raw socket here and not have to open a new one with each query? */
if ((fd = socket(af, SOCK_DGRAM, 0)) < 0)
return (0);
@@ -101,6 +101,9 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
}
close(fd);
return ifr.ifr_mtu;
+ } else {
+ return (0);
+ }
}
#endif
