[Openvpn-devel,v2] init: check parameters for NULL before strlen() in send_cc_message
Commit Message
From: Razvan Cojocaru <razvanc@mailbox.org>
management_callback_send_cc_message() called strlen(parameters) before
its own NULL check. Only count parameters and the separator when set,
and drop the cppcheck suppression for it.
Change-Id: Ib9164e1c8f5e02a2253bbb3b2363a4f9f31c8bdb
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2085
---
This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2085
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>
@@ -198,12 +198,6 @@
<fileName>src/openvpn/dco_freebsd.c</fileName>
<symbolName>buf</symbolName>
</suppress>
- <!-- IGN: strlen(NULL) is not nice code, but seems to work -->
- <suppress>
- <id>nullPointerRedundantCheck</id>
- <fileName>src/openvpn/init.c</fileName>
- <symbolName>parameters</symbolName>
- </suppress>
<!-- FP: cppcheck doesn't understand ZeroMemory -->
<suppress>
<id>redundantAssignment</id>
@@ -299,7 +299,11 @@
management_callback_send_cc_message(void *arg, const char *command, const char *parameters)
{
struct context *c = (struct context *)arg;
- size_t len = strlen(command) + 1 + strlen(parameters) + 1;
+ size_t len = strlen(command) + 1;
+ if (parameters)
+ {
+ len += 1 + strlen(parameters);
+ }
if (len > PUSH_BUNDLE_SIZE)
{
return false;