Skip to content

Commit

Permalink
vtc_varnish: Use a longer buffer during launch
Browse files Browse the repository at this point in the history
When TMPDIR is much longer than /tmp, it becomes easy to run out of
abuf. Since abuf and pbuf are initially used to hold an IP address
and a port number, it becomes explicit in their declaration. Likewise
the new lbuf may hold a file name and safely be reused for CLI auth
and other purposes.
  • Loading branch information
dridi committed May 7, 2024
1 parent ae65ef4 commit 5317450
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions bin/varnishtest/vtc_varnish.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ varnish_launch(struct varnish *v)
{
struct vsb *vsb, *vsb1;
int i, nfd, asock;
char abuf[128], pbuf[128];
char abuf[VTCP_ADDRBUFSIZE];
char pbuf[VTCP_PORTBUFSIZE];
char lbuf[PATH_MAX];
struct pollfd fd[3];
enum VCLI_status_e u;
const char *err;
Expand Down Expand Up @@ -506,19 +508,19 @@ varnish_launch(struct varnish *v)
if (u != CLIS_AUTH)
vtc_fatal(v->vl, "CLI auth demand expected: %u %s", u, r);

bprintf(abuf, "%s/_.secret", v->workdir);
nfd = open(abuf, O_RDONLY);
bprintf(lbuf, "%s/_.secret", v->workdir);
nfd = open(lbuf, O_RDONLY);
assert(nfd >= 0);

assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 7);
bstrcpy(abuf, "auth ");
VCLI_AuthResponse(nfd, r, abuf + 5);
assert(sizeof lbuf >= CLI_AUTH_RESPONSE_LEN + 7);
bstrcpy(lbuf, "auth ");
VCLI_AuthResponse(nfd, r, lbuf + 5);
closefd(&nfd);
free(r);
r = NULL;
strcat(abuf, "\n");
strcat(lbuf, "\n");

u = varnish_ask_cli(v, abuf, &r);
u = varnish_ask_cli(v, lbuf, &r);
if (vtc_error)
return;
if (u != CLIS_OK)
Expand Down

0 comments on commit 5317450

Please sign in to comment.