BUG/MINOR: ssl: potential null pointer dereference in ckchs_dup()
authorEric Salama <esalama@haproxy.com>
Tue, 23 Feb 2021 15:50:57 +0000 (16:50 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 26 Feb 2021 08:50:35 +0000 (09:50 +0100)
commitb77cb98b780d4bdd9eb9ebf62a75cefbf21d4103
tree200d461c3651c0bc83385ffb84a242d6f47e60f4
parent9b8c904fa1822fd8d4e46a99a5d81e1f9956bb78
BUG/MINOR: ssl: potential null pointer dereference in ckchs_dup()

A potential null pointer dereference was reported with an old gcc
version (6.5)

    src/ssl_ckch.c: In function 'cli_parse_set_cert':
    src/ssl_ckch.c:844:7: error: potential null pointer dereference [-Werror=null-dereference]
      if (!ssl_sock_copy_cert_key_and_chain(src->ckch, dst->ckch))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/ssl_ckch.c:844:7: error: potential null pointer dereference [-Werror=null-dereference]
    src/ssl_ckch.c: In function 'ckchs_dup':
    src/ssl_ckch.c:844:7: error: potential null pointer dereference [-Werror=null-dereference]
      if (!ssl_sock_copy_cert_key_and_chain(src->ckch, dst->ckch))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/ssl_ckch.c:844:7: error: potential null pointer dereference [-Werror=null-dereference]

This could happen if ckch_store_new() fails to allocate memory and returns NULL.

This patch must be backported with 8f71298 since it was wrongly fixed and
the bug could happen.

Must be backported as far as 2.2.

(cherry picked from commit 6ac61e39c491f6ca5a1843c787da2e92818ee02a)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
src/ssl_ckch.c