[master] fd9e40dba stricter magic checks
Guillaume Quintard
guillaume at varnish-software.com
Fri Feb 1 19:06:09 UTC 2019
commit fd9e40dba9470c8e4242428a2c5ce774f754ccea
Author: Guillaume Quintard <guillaume at varnish-software.com>
Date: Thu Jan 31 14:22:20 2019 -0800
stricter magic checks
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 9b4f5fedb..76adf6ef6 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -429,6 +429,10 @@ VRT_r_obj_storage(VRT_CTX)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
+ AN(ctx->req->objcore->stobj);
+ CHECK_OBJ_NOTNULL(ctx->req->objcore->stobj->stevedore,
+ STEVEDORE_MAGIC);
return (ctx->req->objcore->stobj->stevedore);
}
@@ -673,6 +677,8 @@ VRT_r_req_xid(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->req->http, HTTP_MAGIC);
+ AN(ctx->req->vsl);
return (WS_Printf(ctx->req->http->ws, "%u",
VXID(ctx->req->vsl->wid)));
@@ -684,6 +690,8 @@ VRT_r_bereq_xid(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->bo->bereq, HTTP_MAGIC);
+ AN(ctx->bo->vsl);
return (WS_Printf(ctx->bo->bereq->ws, "%u",
VXID(ctx->bo->vsl->wid)));
@@ -692,15 +700,26 @@ VRT_r_bereq_xid(VRT_CTX)
VCL_STRING
VRT_r_sess_xid(VRT_CTX)
{
+ struct sess *sp;
+ struct http *http;
+
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- if (VALID_OBJ(ctx->req, REQ_MAGIC))
- return (WS_Printf(ctx->req->http->ws, "%u",
- VXID(ctx->req->sp->vxid)));
+ if (ctx->req) {
+ CHECK_OBJ(ctx->req, REQ_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->req->http, HTTP_MAGIC);
+ sp = ctx->req->sp;
+ http = ctx->req->http;
+ } else {
+ CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->bo->bereq, HTTP_MAGIC);
+ sp = ctx->bo->sp;
+ http = ctx->bo->bereq;
+ }
- CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
- return (WS_Printf(ctx->bo->bereq->ws, "%u",
- VXID(ctx->bo->sp->vxid)));
+ CHECK_OBJ_NOTNULL(http, HTTP_MAGIC);
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ return (WS_Printf(http->ws, "%u", VXID(sp->vxid)));
}
/*--------------------------------------------------------------------
@@ -763,9 +782,10 @@ VRT_r_local_##var(VRT_CTX) \
struct sess *sp; \
\
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
- if (VALID_OBJ(ctx->req, REQ_MAGIC)) \
+ if (ctx->req) { \
+ CHECK_OBJ(ctx->req, REQ_MAGIC); \
sp = ctx->req->sp; \
- else { \
+ } else { \
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \
sp = ctx->bo->sp; \
} \
diff --git a/lib/libvmod_unix/vmod_unix.c b/lib/libvmod_unix/vmod_unix.c
index 59bbb2d8e..4388d58d4 100644
--- a/lib/libvmod_unix/vmod_unix.c
+++ b/lib/libvmod_unix/vmod_unix.c
@@ -67,9 +67,12 @@ get_sp(VRT_CTX)
{
struct sess *sp;
- if (VALID_OBJ(ctx->req, REQ_MAGIC))
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+
+ if (ctx->req) {
+ CHECK_OBJ(ctx->req, REQ_MAGIC);
sp = ctx->req->sp;
- else {
+ } else {
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
sp = ctx->bo->sp;
}
More information about the varnish-commit
mailing list