[master] 96bc829f3 vcc: Ensure the authority does not contain a :<port>
Nils Goroll
nils.goroll at uplex.de
Mon Feb 10 15:02:05 UTC 2025
commit 96bc829f3c1da738032c3fe0590072728904d834
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Feb 7 10:32:35 2025 +0100
vcc: Ensure the authority does not contain a :<port>
Fixes #3963
diff --git a/bin/varnishtest/tests/c00042.vtc b/bin/varnishtest/tests/c00042.vtc
index 60fd5c994..6268cded9 100644
--- a/bin/varnishtest/tests/c00042.vtc
+++ b/bin/varnishtest/tests/c00042.vtc
@@ -110,7 +110,7 @@ varnish v1 -vcl {
.via = v2;
.host = "${s1_addr}";
.port = "${s1_port}";
- .host_header = "host.com";
+ .host_header = "host.com:1234";
}
sub vcl_recv {
diff --git a/doc/sphinx/reference/vcl-backend.rst b/doc/sphinx/reference/vcl-backend.rst
index 24ffc28fc..6729df72b 100644
--- a/doc/sphinx/reference/vcl-backend.rst
+++ b/doc/sphinx/reference/vcl-backend.rst
@@ -221,6 +221,8 @@ The HTTP authority to use when connecting to this backend. If unset,
``.authority`` can not be an IP address.
+A colon and anything following (signifying a port) is removed from the authority.
+
As of this release, the attribute is only used by ``.via`` connections
as a ``PP2_TYPE_AUTHORITY`` Type-Length-Value (TLV) in the `PROXY2`_
preamble.
diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c
index 7b61703f5..3d4a1779f 100644
--- a/lib/libvcc/vcc_backend.c
+++ b/lib/libvcc/vcc_backend.c
@@ -392,8 +392,9 @@ vcc_ParseHostDef(struct vcc *tl, struct symbol *sym,
vtim_dur first_byte_timeout = NAN;
vtim_dur between_bytes_timeout = NAN;
vtim_dur backend_wait_timeout = NAN;
- char *p;
+ char *p, *pp;
unsigned u;
+ int l;
if (tl->t->tok == ID &&
(vcc_IdIs(tl->t, "none") || vcc_IdIs(tl->t, "None"))) {
@@ -706,8 +707,11 @@ vcc_ParseHostDef(struct vcc *tl, struct symbol *sym,
vcc_ErrWhere(tl, t_val);
}
+ pp = strchr(p, ':');
+ l = (pp == NULL) ? -1 : (int)(pp - p);
+
Fb(tl, 0, "\t.authority = ");
- VSB_quote(tl->fb, p, -1, VSB_QUOTE_CSTR);
+ VSB_quote(tl->fb, p, l, VSB_QUOTE_CSTR);
Fb(tl, 0, ",\n");
}
More information about the varnish-commit
mailing list