Skip to content

Commit

Permalink
Better fix & test for incomplete << nonce cli commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdphk committed Oct 11, 2023
1 parent d0d05af commit 101ffbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions bin/varnishtest/tests/u00000.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ process p1 -expect-text 0 0 "-I file had incomplete CLI command at the end"
process p1 -screen-dump
process p1 -wait

process p1 {
echo 'foobar << blabla > ${tmpdir}/_foobar
process p2 {
echo 'foobar << blabla' > ${tmpdir}/_foobar
exec varnishd -n ${tmpdir}/v0 -d -a :0 -I ${tmpdir}/_foobar 2>&1
} -expect-exit 2 -start

process p1 -expect-text 0 0 "-I file had incomplete CLI command at the end"
process p1 -screen-dump
process p1 -wait
process p2 -expect-text 0 0 "-I file had incomplete CLI command at the end"
process p2 -screen-dump
process p2 -wait
8 changes: 7 additions & 1 deletion lib/libvarnish/vcli_serve.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ cls_feed(struct VCLS_fd *cfd, const char *p, const char *e)
if (*cfd->match == '\0' && (*p == '\r' || *p == '\n')) {
AZ(VSB_finish(cfd->last_arg));
// NB: VAV lib internals trusted
cfd->match = NULL;
REPLACE(cfd->argv[cfd->argc - 1], NULL);
REPLACE(cfd->argv[cfd->argc - 2], NULL);
cfd->argv[cfd->argc - 2] =
Expand Down Expand Up @@ -522,7 +523,12 @@ cls_close_fd(struct VCLS *cs, struct VCLS_fd *cfd)
CHECK_OBJ_NOTNULL(cfd, VCLS_FD_MAGIC);

VTAILQ_REMOVE(&cs->fds, cfd, list);
if (cfd->cli->cmd != NULL) {
if (cfd->match != NULL) {
cfd->cli->result = CLIS_TRUNCATED;
if (cs->after != NULL)
cs->after(cfd->cli);
VSB_destroy(&cfd->last_arg);
} else if (cfd->cli->cmd != NULL) {
(void)VSB_finish(cfd->cli->cmd);
cfd->cli->result = CLIS_TRUNCATED;
if (cs->after != NULL)
Expand Down

0 comments on commit 101ffbb

Please sign in to comment.