[#7055] More on VC++ 2005 — Austin Ziegler <halostatue@...>

Okay. I've got Ruby compiling. I'm attempting to get everything in

17 messages 2006/01/05
[#7058] Re: More on VC++ 2005 — nobuyoshi nakada <nobuyoshi.nakada@...> 2006/01/06

Hi,

[#7084] mathn: ugly warnings — hadmut@... (Hadmut Danisch)

Hi,

22 messages 2006/01/10
[#7097] Re: mathn: ugly warnings — Daniel Berger <Daniel.Berger@...> 2006/01/10

Hadmut Danisch wrote:

[#7098] Design contracts and refactoring (was Re: mathn: ugly warnings) — mathew <meta@...> 2006/01/10

Daniel Berger wrote:

[#7118] Re: Design contracts and refactoring (was Re: mathn: ugly warnings) — mathew <meta@...> 2006/01/12

*Dean Wampler *<deanwampler gmail.com> writes:

[#7226] Fwd: Re: Question about massive API changes — "Sean E. Russell" <ser@...>

Hello,

23 messages 2006/01/28
[#7228] Re: Question about massive API changes — Caleb Tennis <caleb@...> 2006/01/28

>

possible bug - does Socket.gethostbyname behave correctly?

From: Sam Roberts <sroberts@...>
Date: 2006-01-31 07:26:56 UTC
List: ruby-core #7260
Socket.gethostbyname gethostbyname(3), which is surprising. It can
return multiple sockaddrs, this is expected, but they are NOT
necessarily all in the indicated address family:

On my system, os x 10.3, I can get, for example:

  ["localhost", [], 30, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001", "\177\000\000\001"]

      and

  ["ensemble.local", [], 30, "\376\200\000\004\000\000\000\000\002\003\223\377\376\255\010\214", "\300\250{\232" ]

Note that getaddrinfo(3) returns a struct hostent, and there all the
addrs in struct hostent.h_addr_list are of the same family.

I'd like to have this clarified, so I know whether to document the
behaviour as is, or not to because its a bug that will be fixed.

Fwiw, note that the Pickaxe (old one, anyhow), doesn't even mention that
the return array can have more than 4 members.

The fix would be simple:

--- socket.c  28 Nov 2005 09:56:45 -0000  1.108.2.37
+++ socket.c  30 Jan 2006 06:28:53 -0000
@@ -1250,7 +1250,14 @@
     rb_ary_push(ary, names);
     rb_ary_push(ary, INT2NUM(addr->ai_family));
     for (ai = addr; ai; ai = ai->ai_next) { 
+      /* Pushing all addresses regardless of address family is not the
+       * behaviour expected of gethostbyname(). All the addresses in struct
+       * hostent->h_addr_list must be of the same family, I think the following
+       * line would fix this.
+ 
+       if(ai->ai_family == addr->ai_family)  <-- suggested fix
+       */
        rb_ary_push(ary, (*ipaddr)(ai->ai_addr, ai->ai_addrlen));
     }
  
     return ary;

Cheers,
Sam


In This Thread

Prev Next