This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: sockaddr_in6
- To: Andi Kleen <ak at muc dot de>
- Subject: Re: sockaddr_in6
- From: Andreas Jaeger <aj at suse dot de>
- Date: 25 Feb 2001 12:02:58 +0100
- Cc: Schmitt David <david at josefine dot ben dot tuwien dot ac dot at>, davem at redhat dot com, kuznet at ms2 dot inr dot ac dot ru, libc-alpha at sources dot redhat dot com
- References: <20010225021101.A27987@josefine.ben.tuwien.ac.at><20010225102147.A898@fred.local>
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