X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 	tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Message-ID: <4A82F7FB.3000609@sipxx.com>
Date: Wed, 12 Aug 2009 13:12:27 -0400
From: cygwin <karl@sipxx.com>
User-Agent: Thunderbird 2.0.0.22 (Windows/20090605)
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: [1.7] IPv6 accept() fails if address_len is < sizeof(sockaddr_in6)   [was Re: PATCH  /usr/include/X11/Xtrans/Xtranssock.c   [WAS: Re: xhost   package   not compiled for IPv6]]
References: <4A78A511.8020109@sipxx.com> <4A803D7C.6070800@dronecode.org.uk> <4A825EE5.5020709@sipxx.com> <4A82BB83.1090908@dronecode.org.uk> <4A82C835.9030504@dronecode.org.uk>
In-Reply-To: <4A82C835.9030504@dronecode.org.uk>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com


The opengroup man page indeed specifies the address to be truncated if 
the storage size is too small. I wonder, however, what kind of sense 
that makes.
Of what use would the truncated address be? This might also require 
applications to verify the integrity of the data returned even if 
accept() returns successfully.
However, Linux also has accept() returning successfully in this case.
For compatibility, the Cygwin implementation should probably be faithful 
to the *NIX behavior and not the Windows practice, since the primary 
idea of Cygwin is to be a portability layer for *NIX apps.




Jon TURNEY wrote:
> On 12/08/2009 13:54, Jon TURNEY wrote:
>> Hmmm... but if it's really the size of the sockname argument which is
>> causing the accept() to fail, this would be a bug in cygwin's accept()
>> implementation, as it's supposed to truncate the data written to the
>> sockname, rather than fail if it won't fit [1]. If that actually is the
>> case, since we don't actually use the peer address here, the code as
>> stands is correct (if a little odd).
>>
>> I suppose I need to write a small test case to look at this...
>>
>> [1] http://www.opengroup.org/onlinepubs/009695399/functions/accept.html
>
> A couple of small programs which hopefully demonstrate this problem.
>
> (As is, the connection fails, but uncommenting the alternate 
> definition of cliaddr in listener.c allows it to work)
>
> I'd hazard a guess that perhaps this is because the underlying winsock 
> accept() doesn't have this truncate behaviour and considers a 
> too-small address_len an error.
> ------------------------------------------------------------------------
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

