From 1ebe659bd5d1d9cf242d60dfc8c823487c5e7cf1 Mon Sep 17 00:00:00 2001 From: henri Date: Sat, 29 Jun 2013 18:36:24 +0000 Subject: [PATCH] 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. --- scripts/address-info.nse | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/address-info.nse b/scripts/address-info.nse index bab6e8e33..ecc4a165f 100644 --- a/scripts/address-info.nse +++ b/scripts/address-info.nse @@ -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