From 6437455da526cb71986515387de5211f1180e03b Mon Sep 17 00:00:00 2001 From: "jyong2.kim" Date: Tue, 28 Apr 2015 14:30:53 +0900 Subject: [PATCH] Fix bug about size of string. 1. fix size of string on strncpy Change-Id: Ia314be019be586cb56fabcf2ffebac48c367f426 Signed-off-by: jyong2.kim Reviewed-on: https://gerrit.iotivity.org/gerrit/851 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka Tested-by: Madan Lanka --- service/notification-manager/NotificationManager/src/hosting.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/service/notification-manager/NotificationManager/src/hosting.c b/service/notification-manager/NotificationManager/src/hosting.c index f0370a1..772a6ae 100755 --- a/service/notification-manager/NotificationManager/src/hosting.c +++ b/service/notification-manager/NotificationManager/src/hosting.c @@ -600,7 +600,7 @@ MirrorResourceList *buildMirrorResourceList(OCDoHandle handle, OCClientResponse continue; } snprintf(mirrorResource->address[OIC_SOURCE_ADDRESS], - sizeof(mirrorResource->address[OIC_SOURCE_ADDRESS]), "%s", sourceaddr); + sizeof(char) * OIC_STRING_MAX_VALUE, "%s", sourceaddr); mirrorResource->address[OIC_MIRROR_ADDRESS] = (char *)malloc(sizeof(char) * OIC_STRING_MAX_VALUE); @@ -611,7 +611,7 @@ MirrorResourceList *buildMirrorResourceList(OCDoHandle handle, OCClientResponse continue; } snprintf(mirrorResource->address[OIC_MIRROR_ADDRESS], - sizeof(mirrorResource->address[OIC_MIRROR_ADDRESS]), "0.0.0.0:00"); + sizeof(char) * OIC_STRING_MAX_VALUE, "0.0.0.0:00"); if (OC_STACK_OK != insertMirrorResource(retList, mirrorResource)) { @@ -680,7 +680,7 @@ MirrorResource *buildMirrorResource(cJSON *ocArray_sub) memset(mirrorResource->prop.resourceType[k], '\0', OIC_STRING_MAX_VALUE); strncpy(mirrorResource->prop.resourceType[k], cJSON_GetArrayItem(tmpJSON, k)->valuestring, - sizeof(mirrorResource->prop.resourceType[k])); + sizeof(char) * OIC_STRING_MAX_VALUE); } } @@ -709,7 +709,7 @@ MirrorResource *buildMirrorResource(cJSON *ocArray_sub) memset(mirrorResource->prop.resourceInterfaceName[k], '\0', OIC_STRING_MAX_VALUE); strncpy(mirrorResource->prop.resourceInterfaceName[k], cJSON_GetArrayItem(tmpJSON, k)->valuestring, - sizeof(mirrorResource->prop.resourceInterfaceName[k])); + sizeof(char) * OIC_STRING_MAX_VALUE); } } -- 2.7.4