From 55572542efe50d110b31a75240b74f6493bece5b Mon Sep 17 00:00:00 2001 From: patrik Date: Thu, 7 Jun 2012 16:06:58 +0000 Subject: [PATCH] Fix for bug in cookie parsing code reported by Ron Bowes; http.lua:757: attempt to perform arithmetic on local 'pos' (a nil value) --- nselib/http.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nselib/http.lua b/nselib/http.lua index f5c5e5477..69adb5a54 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -748,12 +748,21 @@ local function parse_set_cookie(s) if string.sub(s, pos, pos) == "\"" then pos, value = get_quoted_string(s, pos) else - if string.lower(name) == "expires" then + -- account for the possibility of the expires attribute being empty or improperly formatted + local last_pos = pos + + if string.lower(name) == "expires" then -- For version 0 cookies we must allow one comma for "expires". _, pos, value = string.find(s, "([^,]*,[^;,]*)[ \t]*", pos) else _, pos, value = string.find(s, "([^;,]*)[ \t]*", pos) end + + -- account for the possibility of the expires attribute being empty or improperly formatted + if ( not(pos) ) then + _, pos, value = s:find("([^;]*)", last_pos) + end + pos = pos + 1 end if not value then