On Thursday, Feb 2002 at 15:7:44 Hajimu UMEMOTO wrote: 
 > 
 > RFC2553 defines two types of struct sockaddr, one has sa_len and the
 > other doesn't has it.  Though we *BSD has sa_len, non-BSD doesn't have
 > it.

Regardless of sa_len, the size of the structure is already known
by the value of sa_family, which both sockaddrs have.  

 > To keep the portability of the application, we must set the size of
 > the struct sockaddr according to the address family correctly.  So, we
 > should do such sanity checking.

This doesn't impair portability, it improves it.  Since it is more 
permissive, yet still valid, it is compatible with the existing usage.

 > Furthermore, all of KAME delivered getnameinfo() including the version
 > shipped by ISC do the checking.  Changing to only FreeBSD will cause
 > confusion.

Not meaning to hold up glibc as a shining example, but this is how
glibc behaves.  FreeBSD would not be the first.  In fact, this is
needed for compatibility with systems that do honor the second 
parameter.  Just because FreeBSD happens to have the sa_len field
doesn't mean it should take precidence over the specified length.
In fact for portability, the second parameter *must* be honored.
Since sa_len doesn't exist on all systems, and isn't required to
exist, it's value should arguably not be trusted as a portable
app may have left it uninitialized.

The getnameinfo() definition from RFC2553 and the FreeBSD man page
does not require the sa_len field to be initialized prior to calling
getnameinfo().  Since it's not required, it should not be relied upon.

Rob

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message

Reply via email to