From ebf083cb0bfc239a000aea7764cdca42f016affe Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 27 Nov 2018 04:43:16 +0000 Subject: [PATCH] Fix a crash in http scripts when following redirects --- nselib/http.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nselib/http.lua b/nselib/http.lua index 4b602dc61..8933ee56c 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -161,7 +161,12 @@ local function get_host_field(host, port, scheme) if host_header then return host_header end -- If there's no host, we can't invent a name. if not host then return nil end - local number = (type(port) == "number") and port or port.number + local number + if type(port) == "number" then + number = port + port = {number=number, protocol="tcp"} + end + stdnse.debug1("get_host_field: host=%s, port=%s, number=%s", host, port, number) if scheme then -- Caller provided scheme. If it's default, return just the hostname. if number == get_default_port(scheme) then