From 1e6b6b3d62c80fdb2a81ddb129a189b0a5006f0c Mon Sep 17 00:00:00 2001 From: James Lee Date: Fri, 4 Dec 2009 19:55:58 +0000 Subject: [PATCH] fix ipv6 handling for single addresses git-svn-id: file:///home/svn/framework3/trunk@7706 4d416f70-5f16-0410-b530-b9f4589650da --- lib/rex/socket/range_walker.rb | 6 +++--- test/tests/03_range_walker.rb | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/rex/socket/range_walker.rb b/lib/rex/socket/range_walker.rb index 9154fd6122..6090e19b1b 100644 --- a/lib/rex/socket/range_walker.rb +++ b/lib/rex/socket/range_walker.rb @@ -39,8 +39,8 @@ class RangeWalker # Then it's IPv6 # Can't really do much with IPv6 right now, just return it and # hope for the best - addr = Rex::Socket.addr_itoa(Rex::Socket.addr_atoi(arg)) - ranges.push [addr, addr] + addr = Rex::Socket.addr_atoi(arg) + ranges.push [addr, addr, true] elsif arg.include?("/") # Then it's CIDR notation and needs special case if arg =~ /[,-]/ @@ -95,7 +95,7 @@ class RangeWalker @curr_range += 1 @curr_addr = @ranges[@curr_range][0] end - addr = Rex::Socket.addr_itoa(@curr_addr) + addr = Rex::Socket.addr_itoa(@curr_addr, @ranges[@curr_range][2]) @curr_addr += 1 return addr end diff --git a/test/tests/03_range_walker.rb b/test/tests/03_range_walker.rb index 162a3e9753..f6d7660d91 100644 --- a/test/tests/03_range_walker.rb +++ b/test/tests/03_range_walker.rb @@ -4,6 +4,11 @@ require 'rex/socket' require 'rex/socket/range_walker' describe Rex::Socket::RangeWalker do + it "should handle single ipv6 addresses" do + walker = Rex::Socket::RangeWalker.new("::1") + walker.should be_valid + walker.length.should == 1 + end it "should handle ranges" do walker = Rex::Socket::RangeWalker.new("10.1.1.1-2") walker.should be_valid