[master] 7f71fe6 Avoid a length=0 panic where the length can actually be zero.

Poul-Henning Kamp phk at FreeBSD.org
Wed May 13 22:37:03 CEST 2015


commit 7f71fe6e0182cff8aaa5470ffff6c74b67ad8bf7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed May 13 20:35:43 2015 +0000

    Avoid a length=0 panic where the length can actually be zero.
    
    Fixes #1692
    
    Found and diagnosed by:	martin
    Slightly different patch by me.

diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c
index f582b7c..aa31aa4 100644
--- a/bin/varnishd/cache/cache_esi_parse.c
+++ b/bin/varnishd/cache/cache_esi_parse.c
@@ -295,7 +295,9 @@ static void
 vep_emit_common(struct vep_state *vep, ssize_t l, enum vep_mark mark)
 {
 
-	assert(l > 0);
+	assert(l >= 0);
+	if (l == 0)
+		return;
 	assert(mark == SKIP || mark == VERBATIM);
 	if (mark == SKIP)
 		vep_emit_skip(vep, l);
@@ -330,8 +332,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark)
 	if (vep->last_mark != mark && (vep->o_wait > 0 || vep->startup)) {
 		lcb = vep->cb(vep->vc, vep->cb_priv, 0,
 		    mark == VERBATIM ? VGZ_RESET : VGZ_ALIGN);
-		if (lcb - vep->o_last > 0)
-			vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
+		vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
 		vep->o_last = lcb;
 		vep->o_wait = 0;
 	}



More information about the varnish-commit mailing list