BUG/MEDIUM: mworker/cli: crash when trying to access an old PID in prompt mode
authorWilliam Lallemand <wlallemand@haproxy.org>
Fri, 10 Dec 2021 13:14:53 +0000 (14:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 24 Dec 2021 16:58:52 +0000 (17:58 +0100)
commit4a05d6c7f46e7968602594ca007dcd60e58ea23a
treeba6f2e4e45dd20b64ca0d3f5d0dd48db6a3835cd
parent072313a82c3a05885fd953f9d82982ea302d5e6c
BUG/MEDIUM: mworker/cli: crash when trying to access an old PID in prompt mode

The master process encounter a crash when trying to access an old
process which left from the master CLI.

To reproduce the problem, you need a prompt to a previous worker, then
wait for this worker to leave, once it left launch a command from this
prompt. The s->target is then filled with a NULL which is dereferenced
when trying to connect().

This patch fixes the problem by checking if s->target is NULL.

Must be backported as far as 2.0.

(cherry picked from commit dcbe7b91d69f6857961d1545ae71205d9afb905f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit eed682a8a9dfef9a463b28996a5830ff1b8495e3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit dd29e893d66153d9500355cdef1bac3a8908de45)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/cli.c