delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/08/06/09:13:05

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Thu, 6 Aug 2009 15:12:41 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: 1.7.0: getnameinfo bug
Message-ID: <20090806131241.GC15940@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <a837b0ef0908060548q37bdb12blb60a6ffd58162c13 AT mail DOT gmail DOT com> <f60fe000908060601t79d27066ieed01d1ed683fcb2 AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <f60fe000908060601t79d27066ieed01d1ed683fcb2@mail.gmail.com>
User-Agent: Mutt/1.5.19 (2009-02-20)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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

On Aug  6 09:01, Mark J. Reed wrote:
> On Thu, Aug 6, 2009 at 8:48 AM, Zhiming Zhou wrote:
> > This bug happens on every 1.7.0 beta version.
> > I use getnameinfo function with NI_NUMERICHOST flag,
> 
> I assume that it works if you pass NI_NUMERICSERV (returning e.g. "21"
> instead of "ftp" in that case).
> 
> According to the RFC (2553), the specific behavior here is not defined:
> 
>    If the flag bit NI_NUMERICHOST is set, or if the host's name cannot be
>    located in the DNS, the numeric form of the host's address is returned
>    instead of its name (e.g., by calling inet_ntop() instead of
>    getipnodebyaddr()).  If the flag bit NI_NAMEREQD is set, an error is
>    returned if the host's name cannot be located in the DNS.
> 
>    If the flag bit NI_NUMERICSERV is set, the numeric form of the service
>    address is returned (e.g., its port number) instead of its name.  The
>    two NI_NUMERICxxx flags are required to support the "-n" flag that
>    many commands provide.
> 
> The Linux version of the function treats services and hosts alike in
> this regard, but the critical bit of the spec ("or if the host's name
> cannot be located in the DNS") does not have a parallel in the
> description of the behavior with regard to services.   This difference
> is reinforced by the fact that NI_NAMEREQD is only stated to affect
> hostname resolution, and there's no corresponding "service name
> required" flag.
> 
> So it appears that the Cygwin behavior is POSIXly correct, but perhaps
> behaving more like Linux in this regard is desirable.

As I wrote in my other reply to this thread, it's a problem in XP/2003.
Specifying NI_NUMERICSERV shouldn't be necessary in this case, rather it
should return the port number as numeric string.  Microsoft's getnameinfo
man page conveniently notes that this is the desired behaviour according
to section 6.2 of RFC 3493.  That's why this has been fixed in Vista,
which tries to follow the related RFCs as close as possible.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
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

- Raw text -


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