From: Frank Lichtenheld Date: Mon, 25 Mar 2024 07:14:48 +0000 (+0100) Subject: phase2_tcp_server: fix Coverity issue 'Dereference after null check' X-Git-Tag: v2.7_alpha1~277 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e8c629fe64c67ea0a8454753be99db44df7ce53e;p=thirdparty%2Fopenvpn.git phase2_tcp_server: fix Coverity issue 'Dereference after null check' As Coverity says: Either the check against null is unnecessary, or there may be a null pointer dereference. In phase2_tcp_server: Pointer is checked against null but then dereferenced anyway There is only one caller (link_socket_init_phase2) and it already has an ASSERT(sig_info). So use that here was well. v2: - fix cleanly by actually asserting that sig_info is defined Change-Id: I8ef199463d46303129a3f563fd9eace780a58b8a Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Message-Id: <20240325071448.12143-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28452.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 57eaee21c..d2b82d5d6 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2005,7 +2005,8 @@ static void phase2_tcp_server(struct link_socket *sock, const char *remote_dynamic, struct signal_info *sig_info) { - volatile int *signal_received = sig_info ? &sig_info->signal_received : NULL; + ASSERT(sig_info); + volatile int *signal_received = &sig_info->signal_received; switch (sock->mode) { case LS_MODE_DEFAULT: @@ -2031,7 +2032,7 @@ phase2_tcp_server(struct link_socket *sock, const char *remote_dynamic, false); if (!socket_defined(sock->sd)) { - register_signal(sig_info, SIGTERM, "socket-undefiled"); + register_signal(sig_info, SIGTERM, "socket-undefined"); return; } tcp_connection_established(&sock->info.lsa->actual);