Merge 0.10->trunk
authorKim Alvefur <zash@zash.se>
Fri, 26 Aug 2016 16:57:53 +0200
changeset 7639 7674cb520557
parent 7636 9ddc9401911f (current diff)
parent 7638 6879a220917b (diff)
child 7640 cccea9136b2d
Merge 0.10->trunk
--- a/net/http/parser.lua	Wed Aug 24 15:58:16 2016 +0200
+++ b/net/http/parser.lua	Fri Aug 26 16:57:53 2016 +0200
@@ -134,6 +134,9 @@
 				if state then -- read body
 					if client then
 						if chunked then
+							if chunk_start and buflen - chunk_start - 2 < chunk_size then
+								return;
+							end -- not enough data
 							if buftable then buf, buftable = t_concat(buf), false; end
 							if not buf:find("\r\n", nil, true) then
 								return;
@@ -150,6 +153,7 @@
 							elseif buflen - chunk_start - 2 >= chunk_size then -- we have a chunk
 								packet.body = packet.body..buf:sub(chunk_start, chunk_start + (chunk_size-1));
 								buf = buf:sub(chunk_start + chunk_size + 2);
+								buflen = buflen - (chunk_start + chunk_size + 2 - 1);
 								chunk_size, chunk_start = nil, nil;
 							else -- Partial chunk remaining
 								break;