BUG/MEDIUM: mcli: always realign wrapping buffers before parsing them
authorWilly Tarreau <w@1wt.eu>
Thu, 20 Jan 2022 07:47:35 +0000 (08:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Jan 2022 03:37:23 +0000 (04:37 +0100)
commit31a5b0bb4932fafb273aba02c5529194de483bee
tree277457c4273dc3d5c3edfaf82c2eaa2046304e52
parentc67d764d8ae636c378951243fa4038e2dedbf7a8
BUG/MEDIUM: mcli: always realign wrapping buffers before parsing them

Pipelined commands easily result in request buffers to wrap, and the
master-cli parser only deals with linear buffers since it needs contiguous
keywords to look for in a list. As soon as a buffer wraps, some commands
are ignored and the parser is called in loops because the wrapped data
do not leave the buffer.

Let's take the easiest path that's already used at the HTTP layer, we
simply realign the buffer if its input wraps. This rarely happens anyway
(typically once per buffer), remains reasonably cheap and guarantees this
cannot happen anymore.

This needs to be backported as far as 2.0.

(cherry picked from commit a4e4d66f701b58da87cad0a2a90dea7e7553bc71)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/cli.c