This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: sockaddr_in6


Andi Kleen <ak@muc.de> writes:

> On Sun, Feb 25, 2001 at 02:11:06AM +0100, Schmitt David wrote:
> > Hi!
> > 
> > Just a short note:
> > sockaddr_in6 in include/linux/in6.h is missing this:
> >    __u32       sin6_scope_id; /* scope id (new in RFC2553) */
> > which exists in the sockaddr_in6 from 2.4.1.
> > 
> > This breaks glibc 2.2.2 getnameinfo (which checks for the size of
> > sockaddr) which in turn breaks OpenSSH (which is where I started
> > tracing this [three hours ago]).
> 
> It's a known bug in glibc, known to the glibc guys. It should not check
> the size. I thought it had been already fixed there.
> 
> Andreas can probably comment.

This is a known problem due to incompatible changes in sockaddr_in6.
Ulrich, can we add the appended patch?  We've tested it extensively and
it works fine.

Andreas

P.S. Ulrich, the patch comes from Hideaki YOSHIFUJI
<yoshfuji@linux-ipv6.org>, I can provide a ChangeLog entry.

--- inet/getnameinfo.c	Wed Dec 13 15:55:31 2000
+++ inet/getnameinfo.c	Wed Dec 13 15:57:33 2000
@@ -63,6 +63,17 @@
 #endif /* min */
 
 
+/* RFC2133 defines sockaddr_in6 without sin6_scope_id.  */
+struct __sockaddr_in6_rfc2133
+{
+  __SOCKADDR_COMMON (sin6_);
+  uint16_t sin6_port;		/* Transport layer port # */
+  uint32_t sin6_flowinfo;	/* IPv6 flow information */
+  struct in6_addr sin6_addr;	/* IPv6 address */
+};
+
+
+
 static char *
 internal_function
 nrl_domainname (void)
@@ -192,7 +203,9 @@
 	return EAI_FAMILY;
       break;
     case AF_INET6:
-      if (addrlen < sizeof (struct sockaddr_in6))
+      /* glibc 2.1.x and linux-2.2.x are based on old spec (RFC2133).
+	 We should allow users to run old binaries.  */
+      if (addrlen < sizeof (struct __sockaddr_in6_rfc2133))
 	return EAI_FAMILY;
       break;
     default:
@@ -295,8 +308,9 @@
 
 		    c = inet_ntop (AF_INET6,
 				   (const void *) &sin6p->sin6_addr, host, hostlen);
-		    scopeid = sin6p->sin6_scope_id;
-		    if (scopeid != 0)
+		      
+		    if (addrlen >= sizeof (struct sockaddr_in6)
+ 			&& (scopeid = sin6p->sin6_scope_id))
 		      {
 			/* Buffer is >= IFNAMSIZ+1.  */
 			char scopebuf[IFNAMSIZ + 1];



-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]