X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fsecurity%2Fsrc%2Faclresource.c;h=6d20938dd45eb5cfa7c25e24f0ce7a1b7195db37;hb=661a651dcd7cb67f980fde28a5901d42d15a00f7;hp=55058c714ea241fc3369e2ead8dd7d131d186586;hpb=24c563ec03a6b314ab7c878d217ea83d02e5ecd9;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/security/src/aclresource.c b/resource/csdk/security/src/aclresource.c index 55058c7..6d20938 100644 --- a/resource/csdk/security/src/aclresource.c +++ b/resource/csdk/security/src/aclresource.c @@ -54,7 +54,7 @@ static void FreeACE(OicSecAcl_t *ace) size_t i; if(NULL == ace) { - OC_LOG (INFO, TAG, "Invalid Parameter"); + OC_LOG (ERROR, TAG, "Invalid Parameter"); return; } @@ -65,14 +65,25 @@ static void FreeACE(OicSecAcl_t *ace) } OICFree(ace->resources); - //Clean Period & Recurrence - for(i = 0; i < ace->prdRecrLen; i++) + //Clean Period + if(ace->periods) { - OICFree(ace->periods[i]); - OICFree(ace->recurrences[i]); + for(i = 0; i < ace->prdRecrLen; i++) + { + OICFree(ace->periods[i]); + } + OICFree(ace->periods); + } + + //Clean Recurrence + if(ace->recurrences) + { + for(i = 0; i < ace->prdRecrLen; i++) + { + OICFree(ace->recurrences[i]); + } + OICFree(ace->recurrences); } - OICFree(ace->periods); - OICFree(ace->recurrences); // Clean Owners OICFree(ace->owners); @@ -331,6 +342,7 @@ OicSecAcl_t * JSONToAclBin(const char * jsonStr) { VERIFY_SUCCESS(TAG, cJSON_Array == jsonRecurObj->type, ERROR); + if(acl->prdRecrLen > 0) { acl->recurrences = (char**)OICCalloc(acl->prdRecrLen, @@ -341,11 +353,12 @@ OicSecAcl_t * JSONToAclBin(const char * jsonStr) for(size_t i = 0; i < acl->prdRecrLen; i++) { jsonRecur = cJSON_GetArrayItem(jsonRecurObj, i); + VERIFY_NON_NULL(TAG, jsonRecur, ERROR); jsonObjLen = strlen(jsonRecur->valuestring) + 1; acl->recurrences[i] = (char*)OICMalloc(jsonObjLen); VERIFY_NON_NULL(TAG, acl->recurrences[i], ERROR); OICStrcpy(acl->recurrences[i], jsonObjLen, - jsonRecur->valuestring); + jsonRecur->valuestring); } } } @@ -424,7 +437,7 @@ static bool UpdatePersistentStorage(const OicSecAcl_t *acl) static OCStackResult RemoveACE(const OicUuid_t * subject, const char * resource) { - OC_LOG(INFO, TAG, "IN RemoveACE"); + OC_LOG(DEBUG, TAG, "IN RemoveACE"); OicSecAcl_t *acl = NULL; OicSecAcl_t *tempAcl = NULL; @@ -433,7 +446,7 @@ static OCStackResult RemoveACE(const OicUuid_t * subject, if(memcmp(subject->id, &WILDCARD_SUBJECT_ID, sizeof(subject->id)) == 0) { - OC_LOG_V (INFO, TAG, "%s received invalid parameter", __func__ ); + OC_LOG_V (ERROR, TAG, "%s received invalid parameter", __func__ ); return OC_STACK_INVALID_PARAM; } @@ -584,7 +597,7 @@ static OCEntityHandlerResult HandleACLGetRequest (const OCEntityHandlerRequest * // Process the REST querystring parameters if(ehRequest->query) { - OC_LOG (INFO, TAG, "HandleACLGetRequest processing query"); + OC_LOG (DEBUG, TAG, "HandleACLGetRequest processing query"); OicUuid_t subject = {.id={0}}; char resource[MAX_URI_LENGTH] = {0}; @@ -646,7 +659,7 @@ exit: OICFree(jsonStr); - OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ehRet); + OC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet); return ehRet; } @@ -671,13 +684,13 @@ static OCEntityHandlerResult HandleACLPostRequest (const OCEntityHandlerRequest // Send payload to request originator SendSRMResponse(ehRequest, ehRet, NULL); - OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ehRet); + OC_LOG_V (DEBUG, TAG, "%s RetVal %d", __func__ , ehRet); return ehRet; } static OCEntityHandlerResult HandleACLDeleteRequest(const OCEntityHandlerRequest *ehRequest) { - OC_LOG (INFO, TAG, "Processing ACLDeleteRequest"); + OC_LOG (DEBUG, TAG, "Processing ACLDeleteRequest"); OCEntityHandlerResult ehRet = OC_EH_ERROR; OicUuid_t subject = {.id={0}}; char resource[MAX_URI_LENGTH] = {0}; @@ -711,7 +724,7 @@ OCEntityHandlerResult ACLEntityHandler (OCEntityHandlerFlag flag, OCEntityHandlerRequest * ehRequest, void* callbackParameter) { - OC_LOG(INFO, TAG, "Received request ACLEntityHandler"); + OC_LOG(DEBUG, TAG, "Received request ACLEntityHandler"); (void)callbackParameter; OCEntityHandlerResult ehRet = OC_EH_ERROR; @@ -723,7 +736,7 @@ OCEntityHandlerResult ACLEntityHandler (OCEntityHandlerFlag flag, if (flag & OC_REQUEST_FLAG) { // TODO : Handle PUT method - OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + OC_LOG (DEBUG, TAG, "Flag includes OC_REQUEST_FLAG"); switch (ehRequest->method) { case OC_REST_GET: