Changeset

7636:7674cb520557

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Fri, 26 Aug 2016 16:57:53 +0200
parents 7633:9ddc9401911f (current diff) 7635:6879a220917b (diff)
children 7637:cccea9136b2d
files
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;