Date: Tue, 8 Apr 2003 12:20:11 -0700 (PDT) From: Larry Lansing <lansil@fuzzynerd.com> To: freebsd-java@FreeBSD.org Subject: Re: java/50729: java/jdk14: broken java.net.NetworkInterface calls (SIOCGIFCONF) Message-ID: <200304081920.h38JKBfF047208@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR java/50729; it has been noted by GNATS. From: Larry Lansing <lansil@fuzzynerd.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Subject: Re: java/50729: java/jdk14: broken java.net.NetworkInterface calls (SIOCGIFCONF) Date: Tue, 8 Apr 2003 15:11:00 -0400 Oops. Forgot to add a "free" to the first call to the SIOCGIFCONF ioctl. Use this patch instead. +5 points for writing a useful patch in a PR. -10 points for including a memory leak. --- NetworkInterface.c.orig Sat Apr 5 12:30:32 2003 +++ NetworkInterface.c Tue Apr 8 15:04:32 2003 @@ -488,14 +488,25 @@ /* need to do a dummy SIOCGIFCONF to determine the buffer size. * SIOCGIFCOUNT doesn't work */ - ifc.ifc_buf = NULL; + buf = (char *)malloc(32768); + if (!buf) { + JNU_ThrowOutOfMemoryError(env, "heap allocation failed"); + (void) close(sock); + return ifs; + } + + ifc.ifc_buf = buf; + ifc.ifc_len = 32768; + if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "ioctl SIOCGIFCONF failed"); close(sock); + free(buf); return ifs; } bufsize = ifc.ifc_len; + free(buf); #else if (ioctl(sock, SIOCGIFNUM, (char *)&numifs) < 0) { NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", -- Lawrence S. Lansing Project Links Technical Manager RPI Math Department http://links.math.rpi.edu/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304081920.h38JKBfF047208>