BUG/MEDIUM: cli: Don't look for payload pattern on empty commands
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 29 Nov 2023 12:20:59 +0000 (13:20 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 29 Nov 2023 14:09:29 +0000 (15:09 +0100)
commitc9418366b4077da673b4d51653e0e599d212f70c
tree72c3eb8526a68abeff5074acb8c9fb3b68499d73
parent24059615a7a45fe95e50d99bd7f56e85b5ad86c1
BUG/MEDIUM: cli: Don't look for payload pattern on empty commands

A regression was introduced by commit 9431aa0bdf ("BUG/MEDIUM: cli: Don't
look for payload pattern on empty commands").

On empty commands (really empty or containing spaces and tabs), the number of
arguments set to 0. However we look for the payload pattern without checking
it. The result is an access at the index -1 in the argument array. It is of
course invalid.

To fix the issue, we just skip this part when there is no argument. Note that
the empty command is still sent to the worker.

This patch should solve the issue #2365. No backport needed.
src/cli.c