www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/08/06/09:01:50

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <a837b0ef0908060548q37bdb12blb60a6ffd58162c13@mail.gmail.com>
References: <a837b0ef0908060548q37bdb12blb60a6ffd58162c13 AT mail DOT gmail DOT com>
Date: Thu, 6 Aug 2009 09:01:33 -0400
Message-ID: <f60fe000908060601t79d27066ieed01d1ed683fcb2@mail.gmail.com>
Subject: Re: 1.7.0: getnameinfo bug
From: "Mark J. Reed" <markjreed AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
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 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.

-- 
Mark J. Reed <markjreed AT gmail DOT com>

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