Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit 101ffbb

Browse files
committed
Better fix & test for incomplete << nonce cli commands.
Fixes #3995
1 parent d0d05af commit 101ffbb

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

bin/varnishtest/tests/u00000.vtc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ process p1 -expect-text 0 0 "-I file had incomplete CLI command at the end"
181181
process p1 -screen-dump
182182
process p1 -wait
183183

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

189-
process p1 -expect-text 0 0 "-I file had incomplete CLI command at the end"
190-
process p1 -screen-dump
191-
process p1 -wait
189+
process p2 -expect-text 0 0 "-I file had incomplete CLI command at the end"
190+
process p2 -screen-dump
191+
process p2 -wait

lib/libvarnish/vcli_serve.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ cls_feed(struct VCLS_fd *cfd, const char *p, const char *e)
428428
if (*cfd->match == '\0' && (*p == '\r' || *p == '\n')) {
429429
AZ(VSB_finish(cfd->last_arg));
430430
// NB: VAV lib internals trusted
431+
cfd->match = NULL;
431432
REPLACE(cfd->argv[cfd->argc - 1], NULL);
432433
REPLACE(cfd->argv[cfd->argc - 2], NULL);
433434
cfd->argv[cfd->argc - 2] =
@@ -522,7 +523,12 @@ cls_close_fd(struct VCLS *cs, struct VCLS_fd *cfd)
522523
CHECK_OBJ_NOTNULL(cfd, VCLS_FD_MAGIC);
523524

524525
VTAILQ_REMOVE(&cs->fds, cfd, list);
525-
if (cfd->cli->cmd != NULL) {
526+
if (cfd->match != NULL) {
527+
cfd->cli->result = CLIS_TRUNCATED;
528+
if (cs->after != NULL)
529+
cs->after(cfd->cli);
530+
VSB_destroy(&cfd->last_arg);
531+
} else if (cfd->cli->cmd != NULL) {
526532
(void)VSB_finish(cfd->cli->cmd);
527533
cfd->cli->result = CLIS_TRUNCATED;
528534
if (cs->after != NULL)

0 commit comments

Comments
 (0)