BUG/MINOR: cli: Fix memory leak on error for _getsocks command
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Feb 2025 14:30:30 +0000 (15:30 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 18 Mar 2025 14:58:30 +0000 (15:58 +0100)
commitcbe470f5f42eac4295fb105cb9b2719346606ff1
tree8eb059e0cb161e8ebbef59d19d0ccc4f76c27c4a
parent158c7de9c6374947fe4e6363209220ad66118ba3
BUG/MINOR: cli: Fix memory leak on error for _getsocks command

Some errors in parse function of _getsocks commands were not properly handled
and immediately returned, leading to a memory leak on cmsgbuf and tmpbuf
buffers.

To fix the issue, instead of immediately return with -1, we jump to "out"
label. Returning 1 intead of -1 in that case is valid.

This was reported by Coverity in #2841: CIDs 1587773 and 1587772.

This patch should be backported as far as 2.4.

(cherry picked from commit 372cc696d44e6853b9f7920f1c2d965736029764)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit e9e1fbb7c858735e1376b069a8db7ca3b98f58ce)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
src/cli.c