From f0d4b083fcce416eea10e3ded0821e1310216af7 Mon Sep 17 00:00:00 2001 From: Greg Lewis Date: Fri, 28 Feb 2003 17:33:10 +0000 Subject: . Rename our internal gethostby{name,addr}_r functions to avoid collisions. Currently gethostbyaddr_r collides with the implementation (in libc!) for FreeBSD 5.x which both uses a different prototype (as per the Linux version) and is marked temporary and not thread safe. Also, limit the scope of these internal implementations to this file. This fixes crashes in networked applications for FreeBSD 5.x. Some tweaks (making the functions static, naming, BSD ifdefs) by me. Submitted by: "Georg-W. Koltermann" --- java/jdk15/files/patch-InetAddressImpl.c | 114 +++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 java/jdk15/files/patch-InetAddressImpl.c (limited to 'java/jdk15') diff --git a/java/jdk15/files/patch-InetAddressImpl.c b/java/jdk15/files/patch-InetAddressImpl.c new file mode 100644 index 000000000000..ddb4f8045b81 --- /dev/null +++ b/java/jdk15/files/patch-InetAddressImpl.c @@ -0,0 +1,114 @@ +$FreeBSD$ + +--- ../src/solaris/native/java/net/InetAddressImpl.c 25 Jan 2003 23:22:26 -0000 1.7 ++++ ../src/solaris/native/java/net/InetAddressImpl.c 28 Feb 2003 09:34:18 -0000 +@@ -25,6 +25,7 @@ + + #include "java_net_InetAddressImpl.h" + ++#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + /* reentrant BIND includes --billh */ + + #include +@@ -33,14 +34,16 @@ + + /* forward declarations --billh */ + ++static + HOST_R_RETURN +-gethostbyname_r(const char *name, struct hostent *hptr, +- HOST_R_ARGS); ++__j_gethostbyname_r(const char *name, struct hostent *hptr, ++ HOST_R_ARGS); + ++static + HOST_R_RETURN +-gethostbyaddr_r(const char *addr, int len, int type, +- struct hostent *hptr, +- HOST_R_ARGS); ++__j_gethostbyaddr_r(const char *addr, int len, int type, ++ struct hostent *hptr, HOST_R_ARGS); ++#endif + + /* + */ +@@ -99,6 +102,8 @@ + + #ifdef __GLIBC__ + gethostbyname_r(hostname, &res, buf, sizeof(buf), &hp, &h_error); ++#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++ hp = __j_gethostbyname_r(hostname, &res, buf, sizeof(buf), &h_error); + #else + hp = gethostbyname_r(hostname, &res, buf, sizeof(buf), &h_error); + #endif +@@ -106,6 +111,9 @@ + #ifdef __GLIBC__ + gethostbyaddr_r(hp->h_addr, hp->h_length, AF_INET, + &res2, buf2, sizeof(buf2), &hp, &h_error); ++#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++ hp = __j_gethostbyaddr_r(hp->h_addr, hp->h_length, AF_INET, ++ &res2, buf2, sizeof(buf2), &h_error); + #else + hp = gethostbyaddr_r(hp->h_addr, hp->h_length, AF_INET, + &res2, buf2, sizeof(buf2), &h_error); +@@ -189,6 +197,8 @@ + /* Try once, with our static buffer. */ + #ifdef __GLIBC__ + gethostbyname_r(hostname, &res, buf, sizeof(buf), &hp, &h_error); ++#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++ hp = __j_gethostbyname_r(hostname, &res, buf, sizeof(buf), &h_error); + #else + hp = gethostbyname_r(hostname, &res, buf, sizeof(buf), &h_error); + #endif +@@ -203,6 +213,9 @@ + #ifdef __GLIBC__ + gethostbyname_r(hostname, &res, tmp, BIG_HENT_BUF_SIZE, + &hp, &h_error); ++#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++ hp = __j_gethostbyname_r(hostname, &res, tmp, BIG_HENT_BUF_SIZE, ++ &h_error); + #else + hp = gethostbyname_r(hostname, &res, tmp, BIG_HENT_BUF_SIZE, + &h_error); +@@ -283,6 +296,9 @@ + #ifdef __GLIBC__ + gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent, + buf, sizeof(buf), &hp, &h_error); ++#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++ hp = __j_gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent, ++ buf, sizeof(buf), &h_error); + #else + hp = gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent, + buf, sizeof(buf), &h_error); +@@ -297,6 +313,9 @@ + #ifdef __GLIBC__ + gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, + &hent, tmp, BIG_HENT_BUF_SIZE, &hp, &h_error); ++#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++ hp = __j_gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, ++ &hent, tmp, BIG_HENT_BUF_SIZE, &h_error); + #else + hp = gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, + &hent, tmp, BIG_HENT_BUF_SIZE, &h_error); +@@ -335,8 +354,9 @@ + static HOST_R_RETURN + copy_hostent(struct hostent *, struct hostent *, HOST_R_COPY_ARGS); + ++static + HOST_R_RETURN +-gethostbyname_r(const char *name, struct hostent *hptr, HOST_R_ARGS) { ++__j_gethostbyname_r(const char *name, struct hostent *hptr, HOST_R_ARGS) { + struct hostent *he = gethostbyname(name); + + HOST_R_ERRNO; +@@ -347,8 +367,9 @@ + return (copy_hostent(he, hptr, HOST_R_COPY)); + } + ++static + HOST_R_RETURN +-gethostbyaddr_r(const char *addr, int len, int type, ++__j_gethostbyaddr_r(const char *addr, int len, int type, + struct hostent *hptr, HOST_R_ARGS) { + struct hostent *he = gethostbyaddr(addr, len, type); + -- cgit v1.2.3