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 e8c629fe64c67ea0a8454753be99db44df7ce53e)
| ... | ... |
@@ -2007,7 +2007,8 @@ static void |
| 2007 | 2007 |
phase2_tcp_server(struct link_socket *sock, const char *remote_dynamic, |
| 2008 | 2008 |
struct signal_info *sig_info) |
| 2009 | 2009 |
{
|
| 2010 |
- volatile int *signal_received = sig_info ? &sig_info->signal_received : NULL; |
|
| 2010 |
+ ASSERT(sig_info); |
|
| 2011 |
+ volatile int *signal_received = &sig_info->signal_received; |
|
| 2011 | 2012 |
switch (sock->mode) |
| 2012 | 2013 |
{
|
| 2013 | 2014 |
case LS_MODE_DEFAULT: |
| ... | ... |
@@ -2033,7 +2034,7 @@ phase2_tcp_server(struct link_socket *sock, const char *remote_dynamic, |
| 2033 | 2033 |
false); |
| 2034 | 2034 |
if (!socket_defined(sock->sd)) |
| 2035 | 2035 |
{
|
| 2036 |
- register_signal(sig_info, SIGTERM, "socket-undefiled"); |
|
| 2036 |
+ register_signal(sig_info, SIGTERM, "socket-undefined"); |
|
| 2037 | 2037 |
return; |
| 2038 | 2038 |
} |
| 2039 | 2039 |
tcp_connection_established(&sock->info.lsa->actual); |