Skip to content

Commit

Permalink
vcc: Ensure the authority does not contain a :<port>
Browse files Browse the repository at this point in the history
First part of #3963
  • Loading branch information
nigoroll committed Feb 7, 2025
1 parent 1f53374 commit cf658eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/varnishtest/tests/c00042.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions doc/sphinx/reference/vcl-backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ The HTTP authority to use when connecting to this backend. If unset,

``.authority = ""`` disables sending an authority.

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.
Expand Down
8 changes: 6 additions & 2 deletions lib/libvcc/vcc_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,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"))) {
Expand Down Expand Up @@ -675,8 +676,11 @@ vcc_ParseHostDef(struct vcc *tl, struct symbol *sym,
t_val = t_host;
p = t_val->dec;

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");
}

Expand Down

0 comments on commit cf658eb

Please sign in to comment.