From: Jihun Ha Date: Mon, 4 Apr 2016 01:12:16 +0000 (+0900) Subject: Fix a wrong conditional statement in oicgroup X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7c32ded070bccb20868674705a521f82964990f;p=contrib%2Fiotivity.git Fix a wrong conditional statement in oicgroup strlen(actionTypeStr) at line 790 was always 0, which is not what it meant to be. After assign a proper string to actionTypeStr, then strlen() function should be used. Change-Id: I2ac7dd5750f54f59eb16e9469fc4dcec5259bcc9 Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/7553 Reviewed-by: Uze Choi Tested-by: jenkins-iotivity --- diff --git a/resource/csdk/stack/src/oicgroup.c b/resource/csdk/stack/src/oicgroup.c index 4997686..383d66a 100755 --- a/resource/csdk/stack/src/oicgroup.c +++ b/resource/csdk/stack/src/oicgroup.c @@ -787,14 +787,23 @@ OCStackResult BuildStringFromActionSet(OCActionSet* actionset, char** desc) } actionTypeStr = (char *)malloc(1024); - if(actionTypeStr != NULL && remaining >= strlen(actionTypeStr) + strlen(ACTION_DELIMITER) + 1) + if(actionTypeStr != NULL) { sprintf(actionTypeStr, "%ld %u", actionset->timesteps, actionset->type); - strncat(temp, actionTypeStr, strlen(actionTypeStr)); - remaining -= strlen(actionTypeStr); - free(actionTypeStr); - strncat(temp, ACTION_DELIMITER, strlen(ACTION_DELIMITER)); - remaining -= strlen(ACTION_DELIMITER); + if(remaining >= strlen(actionTypeStr) + strlen(ACTION_DELIMITER) + 1) + { + strncat(temp, actionTypeStr, strlen(actionTypeStr)); + remaining -= strlen(actionTypeStr); + strncat(temp, ACTION_DELIMITER, strlen(ACTION_DELIMITER)); + remaining -= strlen(ACTION_DELIMITER); + free(actionTypeStr); + } + else + { + free(actionTypeStr); + res = OC_STACK_ERROR; + goto exit; + } } else {