Merge branch 'rubinius-gethostbyname' of https://github.com/jlee-r7/metasploit-framework into jlee-r7-rubinius-gethostbyname

unstable
sinn3r 2012-06-01 00:39:52 -05:00
commit 9d6fc93ed3
1 changed files with 13 additions and 1 deletions

View File

@ -175,6 +175,19 @@ module Socket
ralias = res.shift ralias = res.shift
rtype = res.shift rtype = res.shift
# Rubinius has a bug where gethostbyname returns dotted quads instead of
# NBO, but that's what we want anyway, so just short-circuit here.
if res[0] =~ MATCH_IPV4 || res[0] =~ MATCH_IPV6
res.each { |r|
# if the caller doesn't mind ipv6, just return whatever we have
return r if accept_ipv6
# otherwise, take the first v4 address
return r if r =~ MATCH_IPV4
}
# didn't find one
return nil
end
# Reject IPv6 addresses if we don't accept them # Reject IPv6 addresses if we don't accept them
if not accept_ipv6 if not accept_ipv6
res.reject!{|nbo| nbo.length != 4} res.reject!{|nbo| nbo.length != 4}
@ -371,7 +384,6 @@ module Socket
# Converts a network byte order address to ascii # Converts a network byte order address to ascii
# #
def self.addr_ntoa(addr) def self.addr_ntoa(addr)
# IPv4 # IPv4
if (addr.length == 4) if (addr.length == 4)
return addr.unpack('C4').join('.') return addr.unpack('C4').join('.')