Bug 1026774: Return errors on some rare failure cases in stun_get_mib_addrs. r=mt

This commit is contained in:
Byron Campen [:bwc] 2014-08-29 14:03:17 -07:00
parent d731dc2940
commit 462f51ddbd

View File

@ -239,12 +239,21 @@ stun_get_mib_addrs(nr_local_addr addrs[], int maxaddrs, int *count)
mib[4] = NET_RT_IFLIST;
mib[5] = 0;
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
errx(1, "iflist-sysctl-estimate");
if ((buf = malloc(needed)) == NULL)
ABORT(R_INTERNAL);
}
if ((buf = malloc(needed)) == NULL) {
errx(1, "malloc");
if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
ABORT(R_NO_MEMORY);
}
if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
errx(1, "actual retrieval of interface table");
ABORT(R_INTERNAL);
}
lim = buf + needed;
next = buf;