Skip to content

Commit

Permalink
phase2_tcp_server: fix Coverity issue 'Dereference after null check'
Browse files Browse the repository at this point in the history
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 <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
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 <gert@greenie.muc.de>
(cherry picked from commit e8c629f)
  • Loading branch information
flichtenheld authored and cron2 committed Mar 25, 2024
1 parent 11ca69c commit 5591af1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/openvpn/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,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:
Expand All @@ -2033,7 +2034,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);
Expand Down

0 comments on commit 5591af1

Please sign in to comment.