]> granicus.if.org Git - sudo/commitdiff
Solaris will return EINVAL if the buffer used in SIOCGIFCONF is too
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 14 Jun 2007 16:23:57 +0000 (16:23 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 14 Jun 2007 16:23:57 +0000 (16:23 +0000)
small.  From Klaus Wagner.

interfaces.c

index 4160207003cf9210e0b8ac6a25f172d7482d4775..49d298ecc4abffa002b05d49d807912872d13d49 100644 (file)
@@ -60,6 +60,7 @@ struct rtentry;
 # include <unistd.h>
 #endif /* HAVE_UNISTD_H */
 #include <netdb.h>
+#include <errno.h>
 #ifdef _ISC
 # include <sys/stream.h>
 # include <sys/sioctl.h>
@@ -182,12 +183,12 @@ load_interfaces()
        ifconf->ifc_len = len - sizeof(struct ifconf);
        ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf));
 
-       /* Networking may not be installed in kernel... */
 #ifdef _ISC
        STRSET(SIOCGIFCONF, (caddr_t) ifconf, len);
        if (ioctl(sock, I_STR, (caddr_t) &strioctl) < 0) {
 #else
-       if (ioctl(sock, SIOCGIFCONF, (caddr_t) ifconf) < 0) {
+       /* Note that some kernels return EINVAL if the buffer is too small */
+       if (ioctl(sock, SIOCGIFCONF, (caddr_t) ifconf) < 0 && errno != EINVAL) {
 #endif /* _ISC */
            efree(ifconf_buf);
            (void) close(sock);