From f9e16eacd9f91ce4efc9c77b048ab00eb97da757 Mon Sep 17 00:00:00 2001
From: "Michael Behrns-Miller [case-ubuntu]" <m@bitpost.com>
Date: Thu, 2 Mar 2017 09:46:41 -0500
Subject: [PATCH] Subject: Buffer index protection in the case where client
 does not  receive content length from HTTP server

---
 lib/service.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/service.c b/lib/service.c
index 1b3fc40e..72d78c97 100644
--- a/lib/service.c
+++ b/lib/service.c
@@ -610,7 +610,10 @@ spin_chunks:
 	if (wsi->chunked)
 		return 0;
 
-	wsi->u.http.content_remain -= n;
+	/* if we know the content length, decrement the content remaining */
+	if (wsi->u.http.content_length > 0)
+		wsi->u.http.content_remain -= n;
+
 	if (wsi->u.http.content_remain || !wsi->u.http.content_length)
 		return 0;
 
-- 
GitLab