libgcj: InetAddress.getByName broken on redhat 5.2

Bryce McKinlay bryce@albatross.co.nz
Wed Apr 14 05:52:00 GMT 1999


On a Redhat 5.2 system (and presumibly any other glibc 2.0.7 based
system), InetAddress.getByName throws an exception for any addresses
that are not defined in /etc/hosts

This is due to the broken implentation of gethostbyname_r in glibc - it
does not return a correct error if the temporary buffer supplied to it
is too small. (I presume this is fixed in glibc 2.1?)

The patch below increases the size of the buffer to 1024 so that
gethostbyname_r doesn't fail (glibc uses this value internally, so it
should be sufficient)

regards

  [ bryce ]


RCS file: /cvs/java/libgcj/libjava/java/net/natInetAddress.cc,v
retrieving revision 1.2
diff -u -r1.2 natInetAddress.cc
--- natInetAddress.cc   1999/04/08 13:22:58     1.2
+++ natInetAddress.cc   1999/04/14 12:51:17
@@ -97,7 +97,7 @@
   struct hostent *hptr = NULL;
 #if defined (HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYADDR_R)
   struct hostent hent_r;
-  char fixed_buffer[200];
+  char fixed_buffer[1024];
   char *buffer_r = fixed_buffer;
   int size_r = sizeof (fixed_buffer);
 #endif




More information about the Java mailing list