*** erts/emulator/drivers/common/inet_drv.c Tue Feb 19 15:40:10 2002 --- ../otp_src_R8B-0-fixed/erts/emulator/drivers/common/inet_drv.c Tue Feb 19 15:39:54 2002 *************** *** 746,764 **** erl_exit(1,"Out of virtual memory in malloc (%s)", __FILE__); return ret; } #define ALLOC(X) alloc_wrapper(X) - #if 0 /* Currently not used, perhaps not tested */ static void *realloc_wrapper(void *current, size_t size){ void *ret = sys_realloc(current,size); if(ret == NULL) erl_exit(1,"Out of virtual memory in realloc (%s)", __FILE__); return ret; } #define REALLOC(X,Y) realloc_wrapper(X,Y) - #endif #else /* FATAL_MALLOC */ #define ALLOC(X) sys_alloc(X) #define REALLOC(X,Y) sys_realloc(X,Y) --- 746,762 ---- *************** *** 3158,3191 **** static int inet_ctl_getiflist(inet_descriptor* desc, char** rbuf, int rsize) { struct ifconf ifc; struct ifreq *ifr; ! char buf[BUFSIZ]; ! char sbuf[BUFSIZ]; char* cp; char* cplim; char* sp; ! ifc.ifc_len = sizeof(buf); ! ifc.ifc_buf = buf; ! if (ioctl(desc->s, SIOCGIFCONF, (char *)&ifc) < 0) return ctl_error(sock_errno(), rbuf, rsize); - sp = sbuf; cplim = buf + ifc.ifc_len; /* skip over if's with big ifr_addr's */ for (cp = buf; (cp < cplim); cp += sizeof(ifr->ifr_name)+SIZEA(ifr->ifr_addr)) { ifr = (struct ifreq *) VOIDP(cp); strncpy(sp, ifr->ifr_name, IFNAMSIZ); sp[IFNAMSIZ] = '\0'; while (*sp != '\0') sp++; sp++; } ! return ctl_reply(INET_REP_OK, sbuf, sp - sbuf, rbuf, rsize); } static int inet_ctl_ifget(inet_descriptor* desc, char* buf, int len, --- 3156,3207 ---- static int inet_ctl_getiflist(inet_descriptor* desc, char** rbuf, int rsize) { struct ifconf ifc; struct ifreq *ifr; ! char *buf; ! char *sbuf; char* cp; char* cplim; char* sp; + int buflen; + int res; ! buf = NULL; ! buflen = 0; ! /* loop until we get all available interfaces */ ! do { ! buflen += 4096; ! buf = (char *)REALLOC(buf,buflen); ! ! ifc.ifc_len = buflen; ! ifc.ifc_buf = buf; ! ! if (ioctl(desc->s, SIOCGIFCONF, (char *)&ifc) < 0) { ! sys_free(buf); return ctl_error(sock_errno(), rbuf, rsize); + } + + } while ( (buflen-ifc.ifc_len) < sizeof(struct ifreq) ); + + sp = sbuf = ALLOC(buflen); cplim = buf + ifc.ifc_len; /* skip over if's with big ifr_addr's */ for (cp = buf; (cp < cplim); cp += sizeof(ifr->ifr_name)+SIZEA(ifr->ifr_addr)) { ifr = (struct ifreq *) VOIDP(cp); strncpy(sp, ifr->ifr_name, IFNAMSIZ); sp[IFNAMSIZ] = '\0'; while (*sp != '\0') sp++; sp++; } ! res = ctl_reply(INET_REP_OK, sbuf, sp - sbuf, rbuf, rsize); ! sys_free(buf); ! sys_free(sbuf); ! return res; } static int inet_ctl_ifget(inet_descriptor* desc, char* buf, int len,