From: Todd C. Miller Date: Thu, 14 Jun 2007 16:23:57 +0000 (+0000) Subject: Solaris will return EINVAL if the buffer used in SIOCGIFCONF is too X-Git-Tag: SUDO_1_7_0~553 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f58f6377078ad6ef33c168ff107f4d37c1b60b37;p=sudo Solaris will return EINVAL if the buffer used in SIOCGIFCONF is too small. From Klaus Wagner. --- diff --git a/interfaces.c b/interfaces.c index 416020700..49d298ecc 100644 --- a/interfaces.c +++ b/interfaces.c @@ -60,6 +60,7 @@ struct rtentry; # include #endif /* HAVE_UNISTD_H */ #include +#include #ifdef _ISC # include # include @@ -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);