From: Fredrik Tolf Date: Mon, 4 Oct 2010 22:44:01 +0000 (+0200) Subject: htparser: Enforce no more than Content-Length bytes are passed to the client. X-Git-Tag: 0.3~13 X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=commitdiff_plain;h=5226f7c50ec6ef6a2da9ca8e04d1afca2725e259 htparser: Enforce no more than Content-Length bytes are passed to the client. --- diff --git a/src/htparser.c b/src/htparser.c index 33ceb49..d1b0a1c 100644 --- a/src/htparser.c +++ b/src/htparser.c @@ -283,8 +283,8 @@ void serve(FILE *in, struct conn *conn) if(!hasheader(req, "connection", "keep-alive")) break; } else if((hd = getheader(resp, "content-length")) != NULL) { - dlen = passdata(out, in, -1); - if(dlen != atoo(hd)) + dlen = atoo(hd); + if(passdata(out, in, dlen) != dlen) break; if(!hasheader(req, "connection", "keep-alive")) break; @@ -301,8 +301,8 @@ void serve(FILE *in, struct conn *conn) } else if((hd = getheader(resp, "content-length")) != NULL) { writeresp(in, resp); fprintf(in, "\r\n"); - dlen = passdata(out, in, -1); - if(dlen != atoo(hd)) + dlen = atoo(hd); + if(passdata(out, in, dlen) != dlen) break; } else if(!getheader(resp, "transfer-encoding")) { headappheader(resp, "Transfer-Encoding", "chunked");