[4.1] 456ee02 add WS_Assert_Allocated: assert that ws->s <= a memory region < ws->f
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Thu Jun 15 14:08:11 CEST 2017
commit 456ee023f117b1122d1f44ad0cf18930440af22c
Author: Geoff Simmons <geoff at uplex.de>
Date: Mon Feb 20 11:38:05 2017 +0100
add WS_Assert_Allocated: assert that ws->s <= a memory region < ws->f
Conflicts:
bin/varnishd/cache/cache.h
bin/varnishd/cache/cache_ws.c
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index c035703..e63fdf0 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1047,6 +1047,7 @@ void *WS_Copy(struct ws *ws, const void *str, int len);
char *WS_Snapshot(struct ws *ws);
int WS_Overflowed(const struct ws *ws);
void *WS_Printf(struct ws *ws, const char *fmt, ...) __v_printflike(2, 3);
+void WS_Assert_Allocated(const struct ws *ws, const void *ptr, ssize_t len);
/* cache_rfc2616.c */
void RFC2616_Ttl(struct busyobj *, double now);
diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index f9402d3..3c44599 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -59,6 +59,17 @@ WS_Assert(const struct ws *ws)
assert(*ws->e == 0x15);
}
+void
+WS_Assert_Allocated(const struct ws *ws, const void *ptr, ssize_t len)
+{
+ const char *p = ptr;
+
+ WS_Assert(ws);
+ if (len < 0)
+ len = strlen(p) + 1;
+ assert(p >= ws->s && (p + len) < ws->f);
+}
+
/*
* NB: The id must be max 3 char and lower-case.
* (upper-case the first char to indicate overflow)
@@ -84,7 +95,6 @@ WS_Init(struct ws *ws, const char *id, void *space, unsigned len)
WS_Assert(ws);
}
-
void
WS_MarkOverflow(struct ws *ws)
{
More information about the varnish-commit
mailing list