Subject: Buffer index protection in the case where client does not
authorMichael Behrns-Miller [case-ubuntu] <m@bitpost.com>
Thu, 2 Mar 2017 14:46:41 +0000 (09:46 -0500)
committerAndy Green <andy@warmcat.com>
Thu, 2 Mar 2017 21:41:39 +0000 (05:41 +0800)
 receive content length from HTTP server

lib/service.c

index 48726c1..31c96b1 100644 (file)
@@ -665,7 +665,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;