diff --git a/nspr-ipv6-numerichost.patch b/nspr-ipv6-numerichost.patch new file mode 100644 index 0000000..dc87914 --- /dev/null +++ b/nspr-ipv6-numerichost.patch @@ -0,0 +1,315 @@ +--- mozilla/nsprpub/pr/src/misc/prnetdb.c.orig 2007-01-15 13:44:34.365432000 -0800 ++++ mozilla/nsprpub/pr/src/misc/prnetdb.c 2007-01-15 13:45:24.298333000 -0800 +@@ -39,6 +39,8 @@ + + #include + ++#define PR_AI_NUMERICHOST 0x4000 /* for internal use only */ ++ + /* + * On Unix, the error code for gethostbyname() and gethostbyaddr() + * is returned in the global variable h_errno, instead of the usual +@@ -1775,63 +1777,70 @@ + PR_IMPLEMENT(PRStatus) PR_StringToNetAddr(const char *string, PRNetAddr *addr) + { + PRStatus status = PR_SUCCESS; +- PRIntn rv; ++ PRAddrInfo *infop = NULL; ++ PRNetAddr laddr; + +-#if defined(_PR_HAVE_INET_NTOP) +- rv = inet_pton(AF_INET6, string, &addr->ipv6.ip); +- if (1 == rv) ++ if (NULL == addr) + { +- addr->raw.family = PR_AF_INET6; ++ PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); ++ return PR_FAILURE; + } +- else ++ infop = PR_GetAddrInfoByName(string, PR_AF_UNSPEC, ++ PR_AI_NUMERICHOST|PR_AI_ADDRCONFIG); ++ if (NULL == infop) ++ { ++ PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); ++ return PR_FAILURE; ++ } ++ if (PR_EnumerateAddrInfo(NULL, infop, 0, &laddr) != NULL) + { +- PR_ASSERT(0 == rv); +- /* clean up after the failed inet_pton() call */ +- memset(&addr->ipv6.ip, 0, sizeof(addr->ipv6.ip)); +- rv = inet_pton(AF_INET, string, &addr->inet.ip); +- if (1 == rv) ++ /* pick up the first addr */ ++ if (PR_AF_INET6 == laddr.raw.family) ++ { ++ addr->ipv6.family = laddr.ipv6.family; ++ addr->ipv6.ip = laddr.ipv6.ip; ++ addr->ipv6.scope_id = laddr.ipv6.scope_id; ++ } ++ else if (PR_AF_INET == laddr.raw.family) + { +- addr->raw.family = AF_INET; ++ addr->inet.family = laddr.inet.family; ++ addr->inet.ip = laddr.inet.ip; + } + else + { +- PR_ASSERT(0 == rv); + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + status = PR_FAILURE; + } + } +-#else /* _PR_HAVE_INET_NTOP */ +- rv = StringToV6Addr(string, &addr->ipv6.ip); +- if (1 == rv) { +- addr->raw.family = PR_AF_INET6; +- return PR_SUCCESS; +- } +- PR_ASSERT(0 == rv); +- /* clean up after the failed StringToV6Addr() call */ +- memset(&addr->ipv6.ip, 0, sizeof(addr->ipv6.ip)); +- +- addr->inet.family = AF_INET; +-#ifdef XP_OS2_VACPP +- addr->inet.ip = inet_addr((char *)string); +-#else +- addr->inet.ip = inet_addr(string); +-#endif +- if ((PRUint32) -1 == addr->inet.ip) ++ else + { +- /* +- * The string argument is a malformed address string. +- */ + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + status = PR_FAILURE; + } +-#endif /* _PR_HAVE_INET_NTOP */ +- ++ PR_FreeAddrInfo(infop); + return status; + } + ++static int ++pr_GetNameInfo(const PRNetAddr *addr, size_t addrlen, ++ char *host, size_t hostlen, ++ char *serv, size_t servlen, PRIntn flags); ++ + PR_IMPLEMENT(PRStatus) PR_NetAddrToString( + const PRNetAddr *addr, char *string, PRUint32 size) + { ++#if defined(_PR_HAVE_GETADDRINFO) ++ PRIntn rv = 0; ++ size_t addrlen = 0; ++ ++ if (NULL == string || 0 == size) ++ goto failed; ++ addrlen = PR_NETADDR_SIZE(addr); ++ rv = pr_GetNameInfo(addr, addrlen, string, size, NULL, 0, NI_NUMERICHOST); ++ if (rv != 0) ++ goto failed; ++ return PR_SUCCESS; ++#else + if (PR_AF_INET6 == addr->raw.family) + { + #if defined(_PR_HAVE_INET_NTOP) +@@ -1858,7 +1867,7 @@ + } + + return PR_SUCCESS; +- ++#endif + failed: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return PR_FAILURE; +@@ -1947,6 +1956,7 @@ + typedef struct addrinfo PRADDRINFO; + #define GETADDRINFO getaddrinfo + #define FREEADDRINFO freeaddrinfo ++#define GETNAMEINFO getnameinfo + + #elif defined(_PR_INET6_PROBE) + +@@ -1965,17 +1975,24 @@ + PRADDRINFO **res); + typedef int (FUNC_MODIFIER * FN_FREEADDRINFO) + (PRADDRINFO *ai); ++typedef int (FUNC_MODIFIER * FN_GETNAMEINFO) ++ (const struct sockaddr *addr, int addrlen, ++ char *host, int hostlen, ++ char *serv, int servlen, int flags); + + /* global state */ + static FN_GETADDRINFO _pr_getaddrinfo = NULL; + static FN_FREEADDRINFO _pr_freeaddrinfo = NULL; ++static FN_GETNAMEINFO _pr_getnameinfo = NULL; + + #if defined(VMS) + #define GETADDRINFO_SYMBOL getenv("GETADDRINFO") + #define FREEADDRINFO_SYMBOL getenv("FREEADDRINFO") ++#define GETNAMEINFO_SYMBOL getenv("GETNAMEINFO") + #else + #define GETADDRINFO_SYMBOL "getaddrinfo" + #define FREEADDRINFO_SYMBOL "freeaddrinfo" ++#define GETNAMEINFO_SYMBOL "getnameinfo" + #endif + + PRStatus +@@ -2003,6 +2020,12 @@ + PR_UnloadLibrary(lib); + continue; + } ++ _pr_getnameinfo = (FN_GETNAMEINFO) ++ PR_FindFunctionSymbol(lib, GETNAMEINFO_SYMBOL); ++ if (!_pr_getnameinfo) { ++ PR_UnloadLibrary(lib); ++ continue; ++ } + _pr_freeaddrinfo = (FN_FREEADDRINFO) + PR_FindFunctionSymbol(lib, FREEADDRINFO_SYMBOL); + PR_ASSERT(_pr_freeaddrinfo); +@@ -2020,6 +2043,11 @@ + if (!_pr_getaddrinfo) { + return PR_FAILURE; + } ++ _pr_getnameinfo = (FN_GETNAMEINFO) ++ PR_FindFunctionSymbolAndLibrary(GETNAMEINFO_SYMBOL, &lib); ++ if (!_pr_getnameinfo) { ++ return PR_FAILURE; ++ } + _pr_freeaddrinfo = (FN_FREEADDRINFO) + PR_FindFunctionSymbol(lib, FREEADDRINFO_SYMBOL); + PR_UnloadLibrary(lib); +@@ -2032,6 +2060,7 @@ + + #define GETADDRINFO (*_pr_getaddrinfo) + #define FREEADDRINFO (*_pr_freeaddrinfo) ++#define GETNAMEINFO (*_pr_getnameinfo) + + #endif /* _PR_INET6 */ + +@@ -2048,6 +2077,46 @@ + PRBool has_cname; + } PRAddrInfoFB; + ++static PRBool ++pr_IsValidNumericHost(const char *string) ++{ ++ PRNetAddr addr; ++ PRIntn rv; ++#if defined(_PR_HAVE_INET_NTOP) ++ rv = inet_pton(AF_INET6, string, &addr.ipv6.ip); ++ if (0 < rv) { ++ return PR_TRUE; ++ } ++ PR_ASSERT(0 == rv); ++ memset(&addr.ipv6.ip, 0, sizeof(addr.ipv6.ip)); ++ rv = inet_pton(AF_INET, string, &addr.inet.ip); ++ if (0 < rv) { ++ return PR_TRUE; ++ } ++ return PR_FALSE; ++#else /* _PR_HAVE_INET_NTOP */ ++ rv = StringToV6Addr(string, &addr.ipv6.ip); ++ if (0 < rv) { ++ return PR_TRUE; ++ } ++ PR_ASSERT(0 == rv); ++ /* clean up after the failed StringToV6Addr() call */ ++ memset(&addr.ipv6.ip, 0, sizeof(addr.ipv6.ip)); ++#ifdef XP_OS2_VACPP ++ addr.inet.ip = inet_addr((char *)string); ++#else ++ addr.inet.ip = inet_addr(string); ++#endif ++ if ((PRUint32) -1 == addr.inet.ip) { ++ /* ++ * The string argument is a malformed address string. ++ */ ++ return PR_FALSE; ++ } ++ return PR_TRUE; ++#endif ++} ++ + static PRAddrInfo * + pr_GetAddrInfoByNameFB(const char *hostname, + PRUint16 af, +@@ -2055,6 +2124,13 @@ + { + PRStatus rv; + PRAddrInfoFB *ai; ++ ++ if (flags & PR_AI_NUMERICHOST) { ++ if (!pr_IsValidNumericHost(hostname)) { ++ PR_SetError(PR_BAD_ADDRESS_ERROR, 0); ++ return NULL; ++ } ++ } + /* fallback on PR_GetHostByName */ + ai = PR_NEW(PRAddrInfoFB); + if (!ai) { +@@ -2077,7 +2153,7 @@ + { + /* restrict input to supported values */ + if ((af != PR_AF_INET && af != PR_AF_UNSPEC) || +- (flags & ~ PR_AI_NOCANONNAME) != PR_AI_ADDRCONFIG) { ++ (flags & ~ (PR_AI_NOCANONNAME|PR_AI_NUMERICHOST)) != PR_AI_ADDRCONFIG) { + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return NULL; + } +@@ -2104,6 +2180,7 @@ + + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = (flags & PR_AI_NOCANONNAME) ? 0: AI_CANONNAME; ++ hints.ai_flags |= (flags & PR_AI_NUMERICHOST) ? AI_NUMERICHOST : 0; + hints.ai_family = (af == PR_AF_INET) ? AF_INET : AF_UNSPEC; + + /* +@@ -2139,6 +2216,22 @@ + #endif + } + ++/* ++ * A wrapper function for getnameinfo ++ * Caution: Not implemented for the system that does not have "getnameinfo" ++ */ ++static int ++pr_GetNameInfo(const PRNetAddr *addr, size_t addrlen, ++ char *host, size_t hostlen, ++ char *serv, size_t servlen, PRIntn flags) ++{ ++#if defined(_PR_HAVE_GETADDRINFO) ++ return GETNAMEINFO((const struct sockaddr *)addr, addrlen, host, hostlen, serv, servlen, flags); ++#else ++ return EAI_SYSTEM; /* not implemented */ ++#endif ++} ++ + PR_IMPLEMENT(void *) PR_EnumerateAddrInfo(void *iterPtr, + const PRAddrInfo *base, + PRUint16 port, +--- mozilla/nsprpub/pr/include/md/_winnt.h.orig 2007-01-15 13:44:17.299466000 -0800 ++++ mozilla/nsprpub/pr/include/md/_winnt.h 2007-01-15 13:45:24.286333000 -0800 +@@ -76,6 +76,8 @@ + /* newer ws2tcpip.h provides these */ + #ifndef AI_CANONNAME + #define AI_CANONNAME 0x2 ++#define AI_NUMERICHOST 0x4 ++#define NI_NUMERICHOST 0x02 + struct addrinfo { + int ai_flags; + int ai_family; +--- mozilla/nsprpub/pr/include/md/_win95.h.orig 2007-01-15 13:44:25.152451000 -0800 ++++ mozilla/nsprpub/pr/include/md/_win95.h 2007-01-15 13:45:24.280332000 -0800 +@@ -61,6 +61,8 @@ + /* newer ws2tcpip.h provides these */ + #ifndef AI_CANONNAME + #define AI_CANONNAME 0x2 ++#define AI_NUMERICHOST 0x4 ++#define NI_NUMERICHOST 0x02 + struct addrinfo { + int ai_flags; + int ai_family; diff --git a/nspr.spec b/nspr.spec index bfc994b..4da9264 100644 --- a/nspr.spec +++ b/nspr.spec @@ -1,7 +1,7 @@ Summary: Netscape Portable Runtime Name: nspr Version: 4.6.4 -Release: 1 +Release: 2 License: MPL/GPL/LGPL URL: http://www.mozilla.org/projects/nspr/ Group: System Environment/Libraries @@ -11,6 +11,7 @@ Source1: nspr.pc.in Source2: nspr-config-vars.in Patch1: nspr-config-pc.patch +Patch2: nspr-ipv6-numerichost.patch Provides: mozilla-nspr Obsoletes: mozilla-nspr @@ -44,6 +45,7 @@ Header files for doing development with the Netscape Portable Runtime. cp ./mozilla/nsprpub/config/nspr-config.in ./mozilla/nsprpub/config/nspr-config-pc.in %patch1 -p0 +%patch2 -p0 cp %{SOURCE2} ./mozilla/nsprpub/config/ @@ -120,6 +122,9 @@ cat %{SOURCE1} | sed -e "s,%%libdir%%,%{_libdir},g" \ %{_bindir}/nspr-config %changelog +* Tue Feb 16 2007 Kai Engert - 4.6.4-2 +- Include upstream patch to fix ipv6 support (rhbz 222554) + * Tue Nov 21 2006 Kai Engert - 4.6.4-1 - Update to 4.6.4