[4.1] 50bfa24 Do not possibly underflow rlen

PÃ¥l Hermunn Johansen hermunn at varnish-software.com
Wed Apr 11 12:04:11 UTC 2018


commit 50bfa24ea117ec232d541f1a4eec6b46081aeaa2
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Oct 13 00:45:24 2017 +0200

    Do not possibly underflow rlen
    
    for i < 0, rlen could underflow. We are safe because of the check for
    i < 0 further down, so this change is just a minor cleanup.
    
    Fixes #2444

diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index c688cd0..085d905 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -264,7 +264,7 @@ vbp_poke(struct vbp_target *vt)
 
 	pfd->fd = s;
 	rlen = 0;
-	do {
+	while (1) {
 		pfd->events = POLLIN;
 		pfd->revents = 0;
 		tmo = (int)round((t_end - t_now) * 1e3);
@@ -281,8 +281,10 @@ vbp_poke(struct vbp_target *vt)
 			    sizeof vt->resp_buf - rlen);
 		else
 			i = read(s, buf, sizeof buf);
+		if (i <= 0)
+			break;
 		rlen += i;
-	} while (i > 0);
+	}
 
 	VTCP_close(&s);
 


More information about the varnish-commit mailing list