[master] 5177b99 Fix an assert which was (safe) off by one.

Poul-Henning Kamp phk at FreeBSD.org
Mon Jun 29 10:30:13 CEST 2015


commit 5177b9950ca3ba6c44178cb51e8e2637e7d6d6c7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jun 29 08:20:21 2015 +0000

    Fix an assert which was (safe) off by one.
    
    Strengthen another assert for increased safety.
    
    Fixes: #1749

diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index bdfdf0d..05edd1b 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -201,7 +201,7 @@ void
 http_SetH(const struct http *to, unsigned n, const char *fm)
 {
 
-	assert(n < to->shd);
+	assert(n < to->nhd);
 	AN(fm);
 	to->hd[n].b = TRUST_ME(fm);
 	to->hd[n].e = strchr(to->hd[n].b, '\0');
@@ -816,7 +816,7 @@ HTTP_Encode(const struct http *fm, uint8_t *p0, unsigned l, unsigned how)
 	p = p0;
 	e = p + l;
 	assert(p + 5 <= e);
-	assert(fm->nhd < fm->shd);
+	assert(fm->nhd <= fm->shd);
 	n = HTTP_HDR_FIRST - 3;
 	vbe16enc(p + 2, fm->status);
 	p += 4;



More information about the varnish-commit mailing list