libs/sgi-uhttpd: do not assume env.CONTENT_LENGTH to be a number

env.CONTENT_LENGTH as passed by uhttpd might be a string, so explicitely
convert it using tonumber().

Issue has been reported by Catalin Patulea <cat@vv.carleton.ca>

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
Jo-Philipp Wich 2014-03-28 16:37:03 +00:00
parent de5da20be1
commit 0efb19876b

View file

@ -43,7 +43,7 @@ function handle_request(env)
renv["HTTP_" .. k] = v renv["HTTP_" .. k] = v
end end
local len = env.CONTENT_LENGTH or 0 local len = tonumber(env.CONTENT_LENGTH) or 0
local function recv() local function recv()
if len > 0 then if len > 0 then
local rlen, rbuf = uhttpd.recv(4096) local rlen, rbuf = uhttpd.recv(4096)