[master] c85aa3110 Tolerate a null address string in std.ip()
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed May 22 16:54:08 UTC 2019
commit c85aa3110c6ab841ef33ba95dfbd962c8ed6c351
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed May 22 18:07:45 2019 +0200
Tolerate a null address string in std.ip()
A regression from d7a81fe82ca09c9f3b3a9fd67265de00da7a4315 and the
followup changes from #2993. The new VSS_Resolve{One,First} functions
expect a non-null address string.
diff --git a/bin/varnishtest/tests/m00011.vtc b/bin/varnishtest/tests/m00011.vtc
index 6c761fff4..243e5daf6 100644
--- a/bin/varnishtest/tests/m00011.vtc
+++ b/bin/varnishtest/tests/m00011.vtc
@@ -77,6 +77,11 @@ varnish v1 -vcl+backend {
set resp.http.port11 = std.port(debug.get_ip());
std.timestamp("1.2.3.4 80, p = 443");
+ debug.store_ip(std.ip(req.http.non-existent, server.ip));
+ set resp.http.ip12 = debug.get_ip();
+ set resp.http.port12 = std.port(debug.get_ip());
+ std.timestamp("NULL, server.ip");
+
}
} -start
@@ -110,4 +115,6 @@ client c1 {
expect resp.http.port10 == ${s1_port}
expect resp.http.ip11 == 1.2.3.4
expect resp.http.port11 == 80
+ expect resp.http.ip12 == ${v1_addr}
+ expect resp.http.port12 == ${v1_port}
} -run
diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c
index b0c07298f..52a006205 100644
--- a/lib/libvmod_std/vmod_std_conversions.c
+++ b/lib/libvmod_std/vmod_std_conversions.c
@@ -194,7 +194,7 @@ VCL_IP
vmod_ip(VRT_CTX, struct VARGS(ip) *a)
{
void *p;
- VCL_IP retval;
+ VCL_IP retval = NULL;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (a->valid_fallback)
@@ -206,10 +206,11 @@ vmod_ip(VRT_CTX, struct VARGS(ip) *a)
return (NULL);
}
- retval = VSS_ResolveFirst(
- p, a->s, a->valid_p ? a->p : "80",
- AF_UNSPEC, SOCK_STREAM,
- a->resolve ? 0 : AI_NUMERICHOST|AI_NUMERICSERV);
+ if (a->s != NULL)
+ retval = VSS_ResolveFirst(
+ p, a->s, a->valid_p ? a->p : "80",
+ AF_UNSPEC, SOCK_STREAM,
+ a->resolve ? 0 : AI_NUMERICHOST|AI_NUMERICSERV);
if (retval != NULL)
return (retval);
More information about the varnish-commit
mailing list