diff --git a/nsprpub/pr/include/md/_openvms.h b/nsprpub/pr/include/md/_openvms.h index b0a2af6fef8..abf438f1818 100644 --- a/nsprpub/pr/include/md/_openvms.h +++ b/nsprpub/pr/include/md/_openvms.h @@ -97,6 +97,7 @@ struct ip_mreq { #define _PR_USE_POLL #define _PR_STAT_HAS_ONLY_ST_ATIME #define _PR_NO_LARGE_FILES +#define _PR_STRICT_ADDR_LEN /* IPv6 support */ #ifdef _SOCKADDR_LEN diff --git a/nsprpub/pr/include/private/primpl.h b/nsprpub/pr/include/private/primpl.h index 2501b70072a..f359648a025 100644 --- a/nsprpub/pr/include/private/primpl.h +++ b/nsprpub/pr/include/private/primpl.h @@ -1714,6 +1714,13 @@ struct PRFilePrivate { #endif #if !defined(XP_UNIX) /* BugZilla: 4090 */ PRBool appendMode; +#endif +#ifdef _PR_STRICT_ADDR_LEN + PRUint16 af; /* If the platform requires passing the exact + * length of the sockaddr structure for the + * address family of the socket to socket + * functions like accept(), we need to save + * the address family of the socket. */ #endif _MDFileDesc md; }; diff --git a/nsprpub/pr/src/pthreads/ptio.c b/nsprpub/pr/src/pthreads/ptio.c index 22a703d09b0..2934449129e 100644 --- a/nsprpub/pr/src/pthreads/ptio.c +++ b/nsprpub/pr/src/pthreads/ptio.c @@ -1628,6 +1628,18 @@ static PRFileDesc* pt_Accept( if (pt_TestAbort()) return newfd; +#ifdef _PR_STRICT_ADDR_LEN + if (addr) + { + /* + * Set addr->raw.family just so that we can use the + * PR_NETADDR_SIZE macro. + */ + addr->raw.family = fd->secret->af; + addr_len = PR_NETADDR_SIZE(addr); + } +#endif + osfd = accept(fd->secret->md.osfd, (struct sockaddr*)addr, &addr_len); syserrno = errno; @@ -3417,6 +3429,9 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto) fd = pt_SetMethods(osfd, ftype, PR_FALSE, PR_FALSE); if (fd == NULL) close(osfd); } +#ifdef _PR_STRICT_ADDR_LEN + if (fd != NULL) fd->secret->af = domain; +#endif #if defined(_PR_INET6_PROBE) || !defined(_PR_INET6) if (fd != NULL) { /* @@ -4369,6 +4384,9 @@ PR_IMPLEMENT(PRFileDesc*) PR_ImportTCPSocket(PRInt32 osfd) if (!_pr_initialized) _PR_ImplicitInitialization(); fd = pt_SetMethods(osfd, PR_DESC_SOCKET_TCP, PR_FALSE, PR_TRUE); if (NULL == fd) close(osfd); +#ifdef _PR_STRICT_ADDR_LEN + if (NULL != fd) fd->secret->af = PF_INET; +#endif return fd; } /* PR_ImportTCPSocket */