[Openvpn-devel,XS] Change in openvpn[master]: phase2_tcp_server: fix Coverity issue "Dereference after null check"

Message ID 8094f36bd4c0f3bde973bb1b4c8d206604bac081-HTML@gerrit.openvpn.net
State Superseded
Headers show
Series [Openvpn-devel,XS] Change in openvpn[master]: phase2_tcp_server: fix Coverity issue "Dereference after null check" | expand

Commit Message

d12fk (Code Review) Jan. 9, 2024, 11:09 a.m. UTC
Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/490?usp=email

to review the following change.


Change subject: phase2_tcp_server: fix Coverity issue "Dereference after null check"
......................................................................

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

The check is probably not required since we have an ASSERT(sig_info)
in the caller. But I really didn't want to remove the check. So
make the code consistent instead.

Change-Id: I8ef199463d46303129a3f563fd9eace780a58b8a
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
---
M src/openvpn/socket.c
1 file changed, 4 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/90/490/1

Patch

diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 480f4e5..c158de1 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -2031,7 +2031,10 @@ 
                                         false);
             if (!socket_defined(sock->sd))
             {
-                register_signal(sig_info, SIGTERM, "socket-undefiled");
+                if (signal_received)
+                {
+                    register_signal(sig_info, SIGTERM, "socket-undefined");
+                }
                 return;
             }
             tcp_connection_established(&sock->info.lsa->actual);