Commit 2d37cff7 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Tolerate a null address string in std.ip()

A regression from d7a81fe8 and the
followup changes from #2993. The new VSS_Resolve{One,First} functions
expect a non-null address string.

Conflicts:
	lib/libvmod_std/vmod_std_conversions.c
parent 41d30386
......@@ -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
......@@ -81,10 +81,9 @@ VCL_IP
vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d, VCL_BOOL n, VCL_STRING default_port)
{
void *p;
VCL_IP retval;
VCL_IP retval = NULL;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(s);
AN(d);
assert(VSA_Sane(d));
......@@ -94,8 +93,9 @@ vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d, VCL_BOOL n, VCL_STRING default_port)
return (NULL);
}
retval = VSS_ResolveFirst(p, s, default_port, AF_UNSPEC, SOCK_STREAM,
n ? 0 : AI_NUMERICHOST|AI_NUMERICSERV);
if (s != NULL)
retval = VSS_ResolveFirst(p, s, default_port, AF_UNSPEC,
SOCK_STREAM, n ? 0 : AI_NUMERICHOST|AI_NUMERICSERV);
if (retval != NULL)
return (retval);
......
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