[master] bedaceb Do not possibly underflow rlen
Nils Goroll
nils.goroll at uplex.de
Thu Oct 12 22:47:05 UTC 2017
commit bedaceb355a8522f71e3b1b4b963f59e239a9b1f
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 4bf48ba..e76468d 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -324,7 +324,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);
@@ -341,8 +341,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