Closed Bug 77264 Opened 23 years ago Closed 23 years ago

assert in pt_GetPeerName on 2.4.3 IPv6 kernel

Categories

(NSPR :: NSPR, defect, P2)

4.0.2
x86
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jgmyers, Assigned: wtc)

Details

Attachments

(3 files)

On Linux with a 2.4.3 kernel with IPv6 enabled, I'm getting an assert in 
pt_GetPeerName() with the IsValidNetAddrLen() check.

In /usr/include, sizeof(sockaddr_in6) is 24.  In the kernel, it is 28 as a 
32-bit scope_id field has been appended.

For linux at least we need to be able to accept both lengths.  Any ideas how to 
conditionalize this?
This happens when connecting to an IMAP/SSL server, as the SSL handshake code 
calls the getpeername() method on the lower PRFileDesc.
John,

Are you saying that we pass addrlen (where *addrlen is 24) to
getpeername(), but on return *addrlen is 28?  It would be wrong
for the kernel to do this.
No, we pass an addr_len of sizeof(PRNetAddr), which is significantly larger than 
28.  We then get upset that the kernel returned a value other than 24.
Attached patch Proposed fixSplinter Review
I just applied John's patch and it seems to work for me.
reassign to wtc
Need a little better fix than the proposed patch.
Assignee: larryh → wtc
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → 4.2
Version: 3.0 → 4.0.2
Patch 35732 has been checked in on the trunk and
NSPRPUB_CLIENT_BRANCH of NSPR.

I'm going to attach another patch that conditionalizes
the workaround for glibc 2.1 only because glibc 2.2 or
newer doesn't need it.
Target Milestone: 4.2 → 4.1.2
I would appreciate it if you could give the new patch
(applied to NSPRPUB_CLIENT_BRANCH) a try.
I checked in the following patch on the trunk of NSPR.  This workaround
is only needed for glibc 2.1 because glibc 2.0 does not have struct
sockaddr_in6 and glibc 2.2 has the RFC 2553 compliant struct sockaddr_in6.

Index: mozilla/nsprpub/pr/src/io/prsocket.c
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/pr/src/io/prsocket.c,v
retrieving revision 3.46
diff -u -r3.46 prsocket.c
--- prsocket.c  2001/05/23 04:17:31     3.46
+++ prsocket.c  2001/06/08 19:38:46
@@ -65,7 +65,7 @@
             && (addr->raw.family != AF_UNIX)
 #endif
             && (PR_NETADDR_SIZE(addr) != addr_len)) {
-#if defined(LINUX)
+#if defined(LINUX) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 1
         /*
          * In glibc 2.1, struct sockaddr_in6 is 24 bytes.  In glibc 2.2
          * and in the 2.4 kernel, struct sockaddr_in6 has the scope_id
Index: mozilla/nsprpub/pr/src/pthreads/ptio.c
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/pr/src/pthreads/ptio.c,v
retrieving revision 3.68
diff -u -r3.68 ptio.c
--- ptio.c      2001/05/23 04:17:33     3.68
+++ ptio.c      2001/06/08 19:38:47
@@ -236,7 +236,7 @@
     if ((addr != NULL)
             && (addr->raw.family != AF_UNIX)
             && (PR_NETADDR_SIZE(addr) != addr_len)) {
-#if defined(LINUX)
+#if defined(LINUX) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 1
         /*
          * In glibc 2.1, struct sockaddr_in6 is 24 bytes.  In glibc 2.2
          * and in the 2.4 kernel, struct sockaddr_in6 has the scope_id
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Target Milestone: 4.1.2 → 4.2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: