delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/06/23/08:25:33

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=ebl9KIZoNnwnAKOoqAOehnZaXrQLxHnqi9n0VDEDidxPWaI9id4qt
dbRclxH5mMdX3bEP03BjpD+4nBe4JrYxJRhp/XRtMTJxppl3HJ3pZeeOwqmDilzi
RXsIGHI5t14IQOXvcS3Gqc0nq+0LxNyBCyuxg+CdqdCl8LRLX+aHXg=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=Rqr+UjV+Ns1+qn7QjcbhEgQUG4w=; b=HQfPae3iyee/+qlN6NKMWkfzzP/u
5+SHn22hXy8dxEiD90e401FB74YC09jaoVMzJZmNnfCKt6juDF/L2wwjYXOxtuPK
0eRYeRDy2BJNj7yk083J8pPh6AeibAF0I/W/ip58coU5F1k8nfXtR83GNP/iJOHx
eAfsbRXNzvCWriA=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2
X-HELO: calimero.vinschen.de
Date: Mon, 23 Jun 2014 14:25:10 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: getaddrinfo : Non-recoverable failure in name resolution
Message-ID: <20140623122510.GD1803@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <53A81259 DOT 4080300 AT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <53A81259.4080300@gmail.com>
User-Agent: Mutt/1.5.23 (2014-03-12)

--iVCmgExH7+hIHJ1A
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi Marco,

On Jun 23 13:41, Marco Atzeri wrote:
> Hi,
> the attached two test programs should perform exactly the same call
> to getaddrinfo for 127.0.0.1
>=20
> however on 32 bit
> CYGWIN_NT-6.1-WOW64 1.7.30(0.272/5/3) 2014-05-23 10:36 i686 Cygwin
>=20
>  32 $ ./getaddrinfo_test-1_32
> 127.0.0.1 ai_addr
> 02 00 00 00 7f 00 00 01 00 00 00 00 00 00 00 00
>=20
>  32 $ ./getaddrinfo_test-2_32
> 127.0.0.1 ai_addr
> 02 00 00 00 7f 00 00 01 00 00 00 00 00 00 00 00
>=20
> while on 64 bit
> CYGWIN_NT-6.1 1.7.30(0.272/5/3) 2014-05-23 10:36 x86_64 Cygwin
>=20
> 64 $ ./getaddrinfo_test-1_64
> 127.0.0.1 ai_addr
> 02 00 00 00 7f 00 00 01 00 00 00 00 00 00 00 00
>=20
> 64 $ ./getaddrinfo_test-2_64
> getaddrinfo: Non-recoverable failure in name resolution
>=20
>=20
> Am I missing something ?
> The second way is currently used on postgresql in several places,
> but it seems to fail only for "127.0.0.1"

I don't know why this only fails for "127.0.0.1".  But this is clearly a
problem in the 64 bit Cygwin DLL.

What happens is that the field ai_addrlen is defined as socklen_t in
POSIX, but as size_t in the W32 API.  On 64 bit, socklen_t is 4 bytes
while size_t is 8 bytes.  Setting all the hintp members manually (in
contrast to calloc'ing it or memset'ing it to 0) leaves the 4 upper
bytes of the ai_addrlen untouched.  This in turn leads to a high
probability that ai_addrlen has an invalid value when entering Winsock's
getsockopt.

I'm really surprised this hasn't been hit before.  I'm going to fix that
in Cygwin by setting the upper 4 bytes of ai_addrlen to 0 explicitely.

For the time being, you might prepend

  memset (&hintp, 0, sizeof hintp);

to the code, prior to setting the elements manually.


Thanks for the testcase.  Much appreciated,
Corinna

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--iVCmgExH7+hIHJ1A
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJTqBymAAoJEPU2Bp2uRE+guGgP/joaKW9wFQovpw5XmjeIZ0bP
mL6RXDP9/urWL815FUJoXQXMxWj1tV6hvFZP4HzdexRKWENB7rtfJGOlJeD89S+G
ydt1wjSjzjfxw//Cw8FlCUZyvmIE5cIPYAlfT3YVmWQ9l/+HEd4Q46Wpo8vCygbJ
/ezLbDkHQ9pBwd4Fr3Djo/T2n4tZ/vSS6QZG6ivRWUWi3UPZ2WquWKpFc8PTcAao
QDzJ4hDIZUJnB5SZfzc3urdy+b/4wB4ExjAjEIU9f7tUVDOxienMeT1VDfkB26WP
uNEqT27f+qxaPm6pPw+k+4ZaPNpTKcGjYsoInl9/3r2H6n1aec0EL3ce0AXCT6vn
Qoyezd4RaSWrkEiulvGc5uiooKtOmXV1g3tRsDZLEdyF8EquYka9CNV2pLSA5m6F
b72xX+H1ML7SX7Cq98zrYDfNf2MLcUl0CV7yaZgScWuF6LUcE2HRGEvCn0ho3xnp
kSE1/oMWH3+g38580cc+ITF3H/RurB/KjQMQMN+EZpWh4/b/rR1SLxFSGqHoSJcq
V8Ae8fBNSpZe30Dmkmu8XJIgFrlsrxTJmixz/3BVFM+XfMkGXbABCCZWCnCV2QSu
YvQ1TbX0Z64vcwZ4uOd2QwcadG90sPC0/Q0EIP1gW9B3+avvr4IcJz5tzmUWReN0
t6LRG7qpn5qRNJEMQhRQ
=DHNT
-----END PGP SIGNATURE-----

--iVCmgExH7+hIHJ1A--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019