mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-03 07:45:47 +00:00
fixed for AIX
now deal if num_interfaces == 0 (should not happen)
This commit is contained in:
24
interfaces.c
24
interfaces.c
@@ -163,10 +163,11 @@ void load_interfaces()
|
|||||||
|
|
||||||
/* set i to the subscript of the next interface */
|
/* set i to the subscript of the next interface */
|
||||||
#ifdef HAVE_SA_LEN
|
#ifdef HAVE_SA_LEN
|
||||||
i += sizeof(ifreq.ifr_name) + ifreq.ifr_addr.sa_len;
|
if (ifreq.ifr_addr.sa_len > sizeof(ifreq.ifr_addr))
|
||||||
#else
|
i += sizeof(ifreq.ifr_name) + ifreq.ifr_addr.sa_len;
|
||||||
i += sizeof(struct ifreq);
|
else
|
||||||
#endif /* HAVE_SA_LEN */
|
#endif /* HAVE_SA_LEN */
|
||||||
|
i += sizeof(struct ifreq);
|
||||||
|
|
||||||
/* skip duplicates and interfaces with NULL addresses */
|
/* skip duplicates and interfaces with NULL addresses */
|
||||||
sin = (struct sockaddr_in *) &ifr->ifr_addr;
|
sin = (struct sockaddr_in *) &ifr->ifr_addr;
|
||||||
@@ -231,12 +232,17 @@ void load_interfaces()
|
|||||||
|
|
||||||
/* if there were bogus entries, realloc the array */
|
/* if there were bogus entries, realloc the array */
|
||||||
if (n != num_interfaces) {
|
if (n != num_interfaces) {
|
||||||
interfaces = (struct interface *) realloc(interfaces,
|
/* it is unlikely that num_interfaces will be 0 but who knows... */
|
||||||
sizeof(struct interface) * num_interfaces);
|
if (num_interfaces != 0) {
|
||||||
if (interfaces == NULL) {
|
interfaces = (struct interface *) realloc(interfaces,
|
||||||
perror("realloc");
|
sizeof(struct interface) * num_interfaces);
|
||||||
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
|
if (interfaces == NULL) {
|
||||||
exit(1);
|
perror("realloc");
|
||||||
|
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(void) free(interfaces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user