From: Razvan Cojocaru <[email protected]>

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 <[email protected]>
Acked-by: Frank Lichtenheld <[email protected]>
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 <[email protected]>

        
diff --git a/dev-tools/cppcheck-suppressions.xml 
b/dev-tools/cppcheck-suppressions.xml
index 33337cf..926ecde 100644
--- a/dev-tools/cppcheck-suppressions.xml
+++ b/dev-tools/cppcheck-suppressions.xml
@@ -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>
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 24cf532..6c87865 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -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;


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to