]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
httpc: fix the wrong receive buffer overflow check, fixes #4353
authorJaroslav Kysela <perex@perex.cz>
Mon, 30 Oct 2017 11:12:23 +0000 (12:12 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 1 Nov 2017 08:23:06 +0000 (09:23 +0100)
src/httpc.c

index 4bc2dbbc397628ffe10fe4b605db796de064ef0f..b776e015831e04b7da82ad95cd9250dbb8e27a9e 100644 (file)
@@ -1026,9 +1026,12 @@ retry:
   }
 
   if (hc->hc_rsize < r + hc->hc_rpos) {
-    if (hc->hc_rsize + r > hc->hc_io_size + 20*1024)
+    if (hc->hc_rpos + r > hc->hc_io_size + 20*1024) {
+      tvhtrace(LS_HTTPC, "%04X: overflow, buf %zd pos %zd read %zd io %zd",
+               shortid(hc), hc->hc_rsize, hc->hc_rpos, r, hc->hc_io_size);
       return http_client_flush(hc, -EMSGSIZE);
-    hc->hc_rsize += r;
+    }
+    hc->hc_rsize += hc->hc_rpos + r + 4*1024;
     hc->hc_rbuf = realloc(hc->hc_rbuf, hc->hc_rsize + 1);
   }
   memcpy(hc->hc_rbuf + hc->hc_rpos, buf, r);