]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
clean up *sig_info handling in link_socket_init_phase2()
authorGert Doering <gert@greenie.muc.de>
Mon, 7 Nov 2016 21:44:02 +0000 (22:44 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 8 Nov 2016 08:50:55 +0000 (09:50 +0100)
The code was a mix of "assume that it is not NULL" and "check that
it is not NULL before using" - it cannot be NULL (due to the single
call graph, referencing c->sig with the global context), but for
good measure, add an ASSERT() upon function entry and get rid of
all the individual checks.

Found by Coverity.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1478555042-31299-1-git-send-email-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12931.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/socket.c

index 184c7ad9b36b692f981fbb2868d10dc9e4cb58d2..18e64097386ce9d3f98e9d22ec352604fbe1e562 100644 (file)
@@ -1857,8 +1857,9 @@ link_socket_init_phase2 (struct link_socket *sock,
   int sig_save = 0;
 
   ASSERT (sock);
+  ASSERT (sig_info);
 
-  if (sig_info && sig_info->signal_received)
+  if (sig_info->signal_received)
     {
       sig_save = sig_info->signal_received;
       sig_info->signal_received = 0;
@@ -1879,7 +1880,7 @@ link_socket_init_phase2 (struct link_socket *sock,
   if (sock->inetd)
     {
       phase2_inetd (sock, frame, remote_dynamic,  &sig_info->signal_received);
-      if (sig_info && sig_info->signal_received)
+      if (sig_info->signal_received)
        goto done;
 
     }
@@ -1921,7 +1922,7 @@ link_socket_init_phase2 (struct link_socket *sock,
          goto done;
        }
 
-      if (sig_info && sig_info->signal_received)
+      if (sig_info->signal_received)
        goto done;
 
       if (sock->info.proto == PROTO_TCP_SERVER)
@@ -1942,7 +1943,7 @@ link_socket_init_phase2 (struct link_socket *sock,
       if (sock->sd != -1)
        protect_fd_nonlocal (sock->sd, &sock->info.lsa->actual.dest.addr.sa);
 #endif
-      if (sig_info && sig_info->signal_received)
+      if (sig_info->signal_received)
        goto done;
     }
 
@@ -1950,7 +1951,7 @@ link_socket_init_phase2 (struct link_socket *sock,
   linksock_print_addr(sock);
 
  done:
-  if (sig_save && sig_info)
+  if (sig_save)
     {
       if (!sig_info->signal_received)
        sig_info->signal_received = sig_save;