1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-20 05:09:02 +00:00

Prevent script from crashing when running against ::1.

This case wasn't properly handled. Simply return nil.

It could also return 127.0.0.1 or 127.0.0.0/8 instead
of early exit though I doubt it makes that much sense
for user.
This commit is contained in:
henri
2013-06-29 18:36:24 +00:00
parent b45f3e89f5
commit 1ebe659bd5

View File

@@ -197,9 +197,11 @@ local function do_ipv6(addr)
output = stdnse.output_table()
if matches(addr, "0000:0000:0000:0000:0000:0000:XXXX:XXXX")
and not matches(addr, "0000:0000:0000:0000:0000:0000:0000:0001") then
-- RFC 4291 2.5.5.1. Specifically exclude ::1 for localhost.
if matches(addr, "0000:0000:0000:0000:0000:0000:0000:0001") then
-- ::1 is localhost. Not much to report.
return nil
elseif matches(addr, "0000:0000:0000:0000:0000:0000:XXXX:XXXX") then
-- RFC 4291 2.5.5.1.
local ipv4 = { addr[13], addr[14], addr[15], addr[16] }
return {["IPv4-compatible"]= { ["IPv4 address"] = format_ipv4(ipv4) } }
elseif matches(addr, "0000:0000:0000:0000:0000:ffff:XXXX:XXXX") then