| Message ID | 20260419135116.22170-1-gert@greenie.muc.de |
|---|---|
| State | New |
| Headers | show |
| Series | [Openvpn-devel,v3] Remove various redundant conditionals | expand |
Verified each of the finding by staring at the code for long enough :-) - the
interactive.c one gave me a bit of headache, trying to understand why it
can never underrun (I'm fully in the "check with 'if (thing <= 0)' to be
guarded against miscalculations" camp). Well, it cannot, because we have
a size_t here, so cppcheck is very obviously right - but the code itself
also ensures that we have a 0-byte at the end, and thus wcslen() can never
"escape" the boundaries of "size".
Out they go... test compiled on mingw. And BB all green, of course.
Your patch has been applied to the master branch.
commit 22062deb5dc04670b48511580d576df3c4682b2e
Author: Frank Lichtenheld
Date: Sun Apr 19 15:51:11 2026 +0200
Remove various redundant conditionals
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1613
Message-Id: <20260419135116.22170-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36666.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index c22a2a4..2a3023c 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -1625,10 +1625,7 @@ } else { - if (p[1]) - { - man_state(man, p[1]); - } + man_state(man, p[1]); if (p[2]) { man_state(man, p[2]); @@ -2542,7 +2539,7 @@ { buffer_list_advance(man->connection.out, sent); } - else if (sent < 0) + else { if (man_io_error(man, "send")) { diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index fe210ee..06e3758 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -1837,7 +1837,7 @@ { msg(M_INFO, "PUSH: No NCP or OCC cipher data received from peer."); - if (o->enable_ncp_fallback && !tls_multi->remote_ciphername) + if (o->enable_ncp_fallback) { msg(M_INFO, "Using data channel cipher '%s' since " diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 70af6d2..0c2866c 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -5304,7 +5304,7 @@ struct dns_server *server = dns_server_get(&options->dns_options.servers, priority, &options->dns_options.gc); - if (streq(p[3], "address") && p[4]) + if (streq(p[3], "address")) { for (int i = 4; p[i]; ++i) { diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c index 3a6b272..9fa9363 100644 --- a/src/openvpn/platform.c +++ b/src/openvpn/platform.c @@ -572,7 +572,7 @@ close(fd); return retfname; } - else if (fd == -1 && errno != EEXIST) + else if (errno != EEXIST) { /* Something else went wrong, no need to retry. */ msg(M_WARN | M_ERRNO, "Could not create temporary file '%s'", retfname); diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index d44f25f..99df49c 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -895,7 +895,7 @@ { /* Must have at least three lines. further lines are ignored for * forward compatibility */ - if (!lines->head || !lines->head->next || !lines->head->next->next) + if (!lines->head->next || !lines->head->next->next) { msg(M_WARN, "auth pending control file is not at least " "three lines long."); diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 4268214..473a8d3 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -486,7 +486,7 @@ sud->directory = data; len = wcslen(sud->directory) + 1; size -= len; - if (size <= 0) + if (size == 0) { MsgToEventLog(M_ERR, L"Startup data ends at working directory"); ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event); @@ -496,7 +496,7 @@ sud->options = sud->directory + len; len = wcslen(sud->options) + 1; size -= len; - if (size <= 0) + if (size == 0) { MsgToEventLog(M_ERR, L"Startup data ends at command line options"); ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);