From: jyong2.kim Date: Tue, 28 Apr 2015 05:30:53 +0000 (+0900) Subject: Fix bug about size of string. X-Git-Tag: 1.2.0+RC1~1782 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6437455da526cb71986515387de5211f1180e03b;p=platform%2Fupstream%2Fiotivity.git 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 --- 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); } }