From 77ae58fe3783291f18d93cc31bbb3a4d11931cf5 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 29 Oct 2007 12:06:34 +0000 Subject: [PATCH] More checks, trying to find pointer tango git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2187 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_hash.c | 7 ++++++- varnish-cache/bin/varnishd/hash_classic.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index 869b4bf6..c93a38b8 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -73,6 +73,7 @@ HSH_Prealloc(struct sess *sp) struct storage *st; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); w = sp->wrk; if (w->nobjhead == NULL) { @@ -87,7 +88,8 @@ HSH_Prealloc(struct sess *sp) if (w->nobj == NULL) { st = STV_alloc(sp, params->mem_workspace); XXXAN(st); - w->nobj = (void *)st->ptr; + assert(st->size > sizeof *w->nobj); + w->nobj = (void *)st->ptr; /* XXX: align ? */ st->len = sizeof *w->nobj; memset(w->nobj, 0, sizeof *w->nobj); w->nobj->objstore = st; @@ -122,6 +124,9 @@ HSH_Compare(const struct sess *sp, const struct objhead *obj) unsigned u, v; const char *b; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(obj, OBJHEAD_MAGIC); i = sp->lhashptr - obj->hashlen; if (i) return (i); diff --git a/varnish-cache/bin/varnishd/hash_classic.c b/varnish-cache/bin/varnishd/hash_classic.c index bdee5314..75082ea0 100644 --- a/varnish-cache/bin/varnishd/hash_classic.c +++ b/varnish-cache/bin/varnishd/hash_classic.c @@ -128,6 +128,9 @@ hcl_lookup(const struct sess *sp, struct objhead *noh) unsigned u, v; int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); CHECK_OBJ_ORNULL(noh, OBJHEAD_MAGIC); digest = ~0U; -- 2.39.5