Bugzilla bug 222037: we need to adjust the address family field of
authorwchang0222%aol.com
Thu, 08 Jan 2004 02:30:03 +0000
changeset 3005 c9328ec7d6c5ae46fd5619d7aaa0cce2d4152c3b
parent 3002 3b0747f33359a99b1548f26d507f99912bfb2ff2
child 3016 b643bb0aedd9877b0f360d6e1a7d72938f093ab1
push idunknown
push userunknown
push dateunknown
bugs222037
Bugzilla bug 222037: we need to adjust the address family field of PRNetAddr on return from getpeername. The patch is contributed by Fredrik Holmqvist <thesuckiestemail@yahoo.se>. r=wtc,darin.
pr/src/md/beos/bnet.c
--- a/pr/src/md/beos/bnet.c
+++ b/pr/src/md/beos/bnet.c
@@ -739,16 +739,25 @@ PRStatus
 PRStatus
 _MD_getpeername (PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen)
 {
     PRInt32 rv, err;
 
     rv = getpeername(fd->secret->md.osfd,
                      (struct sockaddr *) addr, (_PRSockLen_t *)addrlen);
 
+#ifdef _PR_HAVE_SOCKADDR_LEN
+    if (rv == 0) {
+        /* ignore the sa_len field of struct sockaddr */
+        if (addr) {
+            addr->raw.family = ((struct sockaddr *) addr)->sa_family;
+        }
+    }
+#endif /* _PR_HAVE_SOCKADDR_LEN */
+
     if (rv < 0) {
         err = _MD_ERRNO();
         _PR_MD_MAP_GETPEERNAME_ERROR(err);
     }
     return rv==0?PR_SUCCESS:PR_FAILURE;
 }
 
 PRStatus