Land #5859, add comparison cases for IP/IPv6 addresses in rex tables

bug/bundler_fix
Brent Cook 2015-08-19 11:52:33 -05:00
commit 99ab64727d
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
1 changed files with 4 additions and 0 deletions

View File

@ -203,6 +203,10 @@ class Table
cmp = Rex::Socket::addr_atoi(a[index]) <=> Rex::Socket::addr_atoi(b[index]) cmp = Rex::Socket::addr_atoi(a[index]) <=> Rex::Socket::addr_atoi(b[index])
elsif a[index] =~ /^[0-9]+$/ and b[index] =~ /^[0-9]+$/ elsif a[index] =~ /^[0-9]+$/ and b[index] =~ /^[0-9]+$/
cmp = a[index].to_i <=> b[index].to_i cmp = a[index].to_i <=> b[index].to_i
elsif a[index].kind_of?(IPAddr) && a[index].kind_of?(IPAddr) && a[index].ipv6? && b[index].ipv4?
cmp = 1
elsif a[index].kind_of?(IPAddr) && b[index].kind_of?(IPAddr) && a[index].ipv4? && b[index].ipv6?
cmp = -1
else else
cmp = a[index] <=> b[index] # assumes otherwise comparable. cmp = a[index] <=> b[index] # assumes otherwise comparable.
end end