Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 145626 Details for
Bug 222554
fix IPv6 support in PR_StringToNetAddr, PR_GetAddrInfoByName
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
nspr-ipv6-numerichost.patch
nspr-ipv6-numerichost.patch (text/plain), 9.16 KB, created by
Wan-Teh Chang
on 2007-01-15 22:07:28 UTC
(
hide
)
Description:
nspr-ipv6-numerichost.patch
Filename:
MIME Type:
Creator:
Wan-Teh Chang
Created:
2007-01-15 22:07:28 UTC
Size:
9.16 KB
patch
obsolete
>--- 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 <string.h> > >+#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;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 222554
:
145537
|
145625
| 145626