Commit 7f9a989f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix NULL deref related to a backend we don't know any more.

Fixes	#1398
parent 9ba514cc
......@@ -301,6 +301,8 @@ VRT_IP_string(const struct vrt_ctx *ctx, VCL_IP ip)
unsigned len;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (ip == NULL)
return (NULL);
len = WS_Reserve(ctx->ws, 0);
p = ctx->ws->f;
VTCP_name(ip, p, len, NULL, 0);
......
......@@ -251,8 +251,14 @@ VRT_r_beresp_backend_name(const struct vrt_ctx *ctx)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC);
return(ctx->bo->vbc->backend->vcl_name);
if (ctx->bo->vbc != NULL) {
CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC);
return (ctx->bo->vbc->backend->vcl_name);
}
if (ctx->bo->director != NULL) {
return (ctx->bo->director->vcl_name);
}
return (NULL);
}
VCL_IP
......@@ -261,8 +267,11 @@ VRT_r_beresp_backend_ip(const struct vrt_ctx *ctx)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC);
return(ctx->bo->vbc->addr);
if (ctx->bo->vbc != NULL) {
CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC);
return(ctx->bo->vbc->addr);
} else
return (NULL);
}
const char *
......
varnishtest "ticket 1398"
varnish v1 -vcl {
backend foo {
.host = "${bad_ip}"; .port = "9080";
}
sub vcl_backend_response {
set beresp.http.X-BE-Name = beresp.backend.name;
set beresp.http.X-BE-IP = beresp.backend.ip;
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 503
expect resp.http.X-BE-Name == foo
expect resp.http.X-BE-IP == ""
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment