static check: noti test unterminated strings 85/21885/2
authorMats Wichmann <mats@linux.com>
Fri, 11 Aug 2017 16:12:55 +0000 (10:12 -0600)
committerPhil Coval <philippe.coval@osg.samsung.com>
Mon, 28 Aug 2017 19:33:57 +0000 (19:33 +0000)
The test strncpy'd three strings using the strlen of the string,
leaving the destination buffer without the string terminator.
strcpy will do the right thing here since in this case the source is
declared as a string which is sure to be terminated.

Change-Id: I85a15ab92b311481015c898f44b034fe49bf55f4
Signed-off-by: Mats Wichmann <mats@linux.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21885
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: George Nash <george.nash@intel.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
service/notification/unittest/NSProviderTest.cpp

index 382c88e..985bd48 100644 (file)
@@ -167,9 +167,9 @@ protected:
 
             g_isStartedStack = true;
 
-            strncpy(g_title, "Title", strlen("Title"));
-            strncpy(g_body, "ContentText", strlen("ContentText"));
-            strncpy(g_sourceName, "OIC", strlen("OIC"));
+            strcpy(g_title, "Title");
+            strcpy(g_body, "ContentText");
+            strcpy(g_sourceName, "OIC");
         }
 
     }