mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 04:09:01 +00:00
Send 414 if the first line is longer than 8096 bytes.
This commit is contained in:
@@ -38,20 +38,22 @@ function url_decode(str)
|
|||||||
function(h) return string.char(tonumber(h,16)) end)
|
function(h) return string.char(tonumber(h,16)) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Read a line of at most 8096 bytes from standard input. Returns the truncated
|
--Read a line of at most 8096 bytes (or whatever the first parameter says)
|
||||||
--string in case we didn't hit the newline. This is here because
|
--from standard input. Returns the string and a boolean value that is true if
|
||||||
--io.stdin:read("*line") could read to memory exhaustion if we received
|
--we hit the newline (defined as "\r" or "\n") or false if the line had to be
|
||||||
--gigabytes of characters with no newline.
|
--truncated. This is here because io.stdin:read("*line") could read to memory
|
||||||
|
--exhaustion if we received gigabytes of characters with no newline.
|
||||||
function read_line(max_len)
|
function read_line(max_len)
|
||||||
local ret = ""
|
local ret = ""
|
||||||
for i = 1, (max_len or 8096) do
|
for i = 1, (max_len or 8096) do
|
||||||
local chr = io.read(1)
|
local chr = io.read(1)
|
||||||
if chr == "\r" or chr == "\n" then
|
if chr == "\r" or chr == "\n" then
|
||||||
return ret
|
return ret, true
|
||||||
end
|
end
|
||||||
ret = ret .. chr
|
ret = ret .. chr
|
||||||
end
|
end
|
||||||
return ret
|
|
||||||
|
return ret, false
|
||||||
end
|
end
|
||||||
|
|
||||||
--The following function and variables was translated from Go to Lua. The
|
--The following function and variables was translated from Go to Lua. The
|
||||||
@@ -254,15 +256,16 @@ do_400 = function() make_error("400 Bad Request") end
|
|||||||
do_403 = function() make_error("403 Forbidden") end
|
do_403 = function() make_error("403 Forbidden") end
|
||||||
do_404 = function() make_error("404 Not Found") end
|
do_404 = function() make_error("404 Not Found") end
|
||||||
do_405 = function() make_error("405 Method Not Allowed") end
|
do_405 = function() make_error("405 Method Not Allowed") end
|
||||||
|
do_414 = function() make_error("414 Request-URI Too Long") end
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
-- End of library section --
|
-- End of library section --
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
input = read_line()
|
input, success = read_line()
|
||||||
|
|
||||||
if input == nil then
|
if not success then
|
||||||
do_400()
|
do_414()
|
||||||
end
|
end
|
||||||
|
|
||||||
if input:sub(-1) == "\r" then
|
if input:sub(-1) == "\r" then
|
||||||
|
|||||||
Reference in New Issue
Block a user