[4.0] 752a95f Ensure that we never call a VDP with a zero length unless we are done.

Lasse Karstensen lkarsten at varnish-software.com
Tue Sep 23 15:09:29 CEST 2014


commit 752a95f1fc5bb60cf7e592dac8f34489623dad7a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jul 29 18:44:17 2014 +0000

    Ensure that we never call a VDP with a zero length unless we are done.
    
    Fixes #1561

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 584a6c6..414ec87 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -883,6 +883,7 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
+	assert(act > VDP_NULL || len > 0);
 	/* Call the present layer, while pointing to the next layer down */
 	i = req->vdp_nxt--;
 	assert(i >= 0 && i < N_VDPS);
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index a92d29f..5d70534 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -76,9 +76,12 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l)
 			oi->st = VTAILQ_FIRST(&oi->obj->store);
 		else
 			oi->st = VTAILQ_NEXT(oi->st, list);
+		while(oi->st != NULL && oi->st->len == 0)
+			oi->st = VTAILQ_NEXT(oi->st, list);
 		if (oi->st != NULL) {
 			*p = oi->st->ptr;
 			*l = oi->st->len;
+			assert(*l > 0);
 			return (OIS_DATA);
 		}
 		return (OIS_DONE);



More information about the varnish-commit mailing list