1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

Avoid a crash by making sure response *has* a location header

This commit is contained in:
dmiller
2019-08-02 04:21:38 +00:00
parent 5ad05bdbab
commit 13d70d9ac7

View File

@@ -58,6 +58,7 @@ action = function (host, port)
if string.match(result, "^HTTP/1.[01] 3%d%d") then if string.match(result, "^HTTP/1.[01] 3%d%d") then
local location = string.match(result, "\n[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn]:[ \t]*(.-)\r?\n") local location = string.match(result, "\n[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn]:[ \t]*(.-)\r?\n")
if location then
local parsed = url.parse(location) local parsed = url.parse(location)
-- Check for a redirect to the same port, but with HTTPS scheme. -- Check for a redirect to the same port, but with HTTPS scheme.
if parsed.scheme == 'https' and tonumber(parsed.port or 443) == port.number and ( if parsed.scheme == 'https' and tonumber(parsed.port or 443) == port.number and (
@@ -73,4 +74,5 @@ action = function (host, port)
end end
end end
end end
end
end end