Commit 8ae052ff authored by Oleksandr Dmytrenko's avatar Oleksandr Dmytrenko

security provisioning cloud c++ fixs

security provisioning cloud c++ fixs

Change-Id: I56f5a67f8f471d935e69cec0527abd7a6a59f686
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
parent 33afa843
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
extern "C" { extern "C" {
#endif // __cplusplus #endif // __cplusplus
extern char *DEFAULT_QUERY; extern const char *DEFAULT_QUERY;
extern char *DEFAULT_PREFIX; extern const char *DEFAULT_PREFIX;
typedef OCStackResult (*UserFunctionCB)(void *params, void **data, OCClientResponse *clientResponse); typedef OCStackResult (*UserFunctionCB)(void *params, void **data, OCClientResponse *clientResponse);
......
...@@ -44,6 +44,10 @@ static OCStackResult handleAclCreateGroupResponse(void *ctx, void **data, ...@@ -44,6 +44,10 @@ static OCStackResult handleAclCreateGroupResponse(void *ctx, void **data,
OCClientResponse *response) OCClientResponse *response)
{ {
OC_UNUSED(ctx); OC_UNUSED(ctx);
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
if (NULL == response->payload) if (NULL == response->payload)
{ {
OIC_LOG(ERROR, TAG, "Receive NULL payload"); OIC_LOG(ERROR, TAG, "Receive NULL payload");
...@@ -74,6 +78,10 @@ static OCStackResult handleAclFindMyGroupResponse(void *ctx, void **data, ...@@ -74,6 +78,10 @@ static OCStackResult handleAclFindMyGroupResponse(void *ctx, void **data,
OCClientResponse *response) OCClientResponse *response)
{ {
OC_UNUSED(ctx); OC_UNUSED(ctx);
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
if (NULL == response->payload) if (NULL == response->payload)
{ {
OIC_LOG(ERROR, TAG, "Receive NULL payload"); OIC_LOG(ERROR, TAG, "Receive NULL payload");
...@@ -83,7 +91,7 @@ static OCStackResult handleAclFindMyGroupResponse(void *ctx, void **data, ...@@ -83,7 +91,7 @@ static OCStackResult handleAclFindMyGroupResponse(void *ctx, void **data,
const OCRepPayload *payload = (const OCRepPayload *)response->payload; const OCRepPayload *payload = (const OCRepPayload *)response->payload;
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 }; size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
stringArray_t *gidlist = OICCalloc(1, sizeof(stringArray_t)); stringArray_t *gidlist = (stringArray_t *)OICCalloc(1, sizeof(stringArray_t));
if (NULL == gidlist) if (NULL == gidlist)
{ {
OIC_LOG(ERROR, TAG, "Can't allocate gidlist"); OIC_LOG(ERROR, TAG, "Can't allocate gidlist");
......
...@@ -45,11 +45,10 @@ ...@@ -45,11 +45,10 @@
static OCStackResult getAclIdFromResponse(void *ctx, void **data, OCClientResponse *response) static OCStackResult getAclIdFromResponse(void *ctx, void **data, OCClientResponse *response)
{ {
OC_UNUSED(ctx); OC_UNUSED(ctx);
if (NULL == response->payload)
{ VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
OIC_LOG(ERROR, TAG, "Receive NULL payload"); VERIFY_NON_NULL_RET(response->payload, TAG, "NULL payload response", OC_STACK_INVALID_PARAM);
return OC_STACK_INVALID_PARAM; VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
}
char *aclid = NULL; char *aclid = NULL;
...@@ -102,8 +101,11 @@ OCStackResult OCCloudGetAclIdByDevice(void *ctx, ...@@ -102,8 +101,11 @@ OCStackResult OCCloudGetAclIdByDevice(void *ctx,
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(deviceId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(deviceId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL, OC_RSRVD_DEVICE_ID, if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s",
deviceId); cloudUri, OC_RSRVD_ACL_ID_URL, OC_RSRVD_DEVICE_ID, deviceId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData; OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, handleGetAclIdByDeviceResponse, NULL); fillCallbackData(&cbData, ctx, callback, handleGetAclIdByDeviceResponse, NULL);
...@@ -124,9 +126,13 @@ OCStackResult OCCloudAclIdCreate(void *ctx, ...@@ -124,9 +126,13 @@ OCStackResult OCCloudAclIdCreate(void *ctx,
VERIFY_NON_NULL_RET(ownerId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(ownerId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(deviceId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(deviceId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s&%s=%s", if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s&%s=%s",
cloudUri, OC_RSRVD_ACL_ID_URL, cloudUri, OC_RSRVD_ACL_ID_URL,
OC_RSRVD_OWNER_ID, ownerId, OC_RSRVD_DEVICE_ID, deviceId); OC_RSRVD_OWNER_ID, ownerId, OC_RSRVD_DEVICE_ID, deviceId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData; OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, handleAclIdCreateResponse, NULL); fillCallbackData(&cbData, ctx, callback, handleAclIdCreateResponse, NULL);
...@@ -145,7 +151,12 @@ OCStackResult OCCloudAclIdDelete(void *ctx, ...@@ -145,7 +151,12 @@ OCStackResult OCCloudAclIdDelete(void *ctx,
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL, OC_RSRVD_ACL_ID, aclId); if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL,
OC_RSRVD_ACL_ID, aclId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData; OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, NULL, NULL); fillCallbackData(&cbData, ctx, callback, NULL, NULL);
...@@ -167,15 +178,13 @@ static OCStackResult handleAclGetInfoResponse(void *ctx, void **data, OCClientRe ...@@ -167,15 +178,13 @@ static OCStackResult handleAclGetInfoResponse(void *ctx, void **data, OCClientRe
OCStackResult result = OC_STACK_OK; OCStackResult result = OC_STACK_OK;
uint8_t *cbor = NULL; uint8_t *cbor = NULL;
size_t size = 0; size_t size = 0;
OicSecAcl_t *acl = NULL;
OC_UNUSED(ctx); OC_UNUSED(ctx);
OC_UNUSED(data); OC_UNUSED(data);
if (NULL == response->payload) VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
{ VERIFY_NON_NULL_RET(response->payload, TAG, "NULL pyload response", OC_STACK_INVALID_PARAM);
OIC_LOG(ERROR, TAG, "Receive NULL payload\n");
return OC_STACK_INVALID_PARAM;
}
result = OCConvertPayload(response->payload, OC_FORMAT_CBOR, &cbor, &size); result = OCConvertPayload(response->payload, OC_FORMAT_CBOR, &cbor, &size);
if (result != OC_STACK_OK) if (result != OC_STACK_OK)
...@@ -184,7 +193,7 @@ static OCStackResult handleAclGetInfoResponse(void *ctx, void **data, OCClientRe ...@@ -184,7 +193,7 @@ static OCStackResult handleAclGetInfoResponse(void *ctx, void **data, OCClientRe
goto exit; goto exit;
} }
OicSecAcl_t *acl = CBORPayloadToCloudAcl(cbor, size); acl = CBORPayloadToCloudAcl(cbor, size);
if (NULL == acl) if (NULL == acl)
{ {
OIC_LOG(ERROR, TAG, "Can't parse CBOR payload"); OIC_LOG(ERROR, TAG, "Can't parse CBOR payload");
...@@ -213,16 +222,21 @@ exit: ...@@ -213,16 +222,21 @@ exit:
} }
OCStackResult OCCloudAclIndividualGetInfo(void *ctx, OCStackResult OCCloudAclIndividualGetInfo(void *ctx,
const char *aclId, const char *aclId,
const char *cloudUri, const char *cloudUri,
OCCloudResponseCB callback) OCCloudResponseCB callback)
{ {
char uri[MAX_URI_LENGTH] = { 0 }; char uri[MAX_URI_LENGTH] = { 0 };
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId); if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL,
aclId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData; OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, handleAclGetInfoResponse, NULL); fillCallbackData(&cbData, ctx, callback, handleAclGetInfoResponse, NULL);
...@@ -231,11 +245,44 @@ OCStackResult OCCloudAclIndividualGetInfo(void *ctx, ...@@ -231,11 +245,44 @@ OCStackResult OCCloudAclIndividualGetInfo(void *ctx,
CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0); CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0);
} }
static bool aceValidate(cloudAce_t *aces)
{
cloudAce_t *ace = NULL;
size_t acllist_count = 0;
LL_FOREACH(aces, ace)
{
size_t reslist_count = 0;
OicSecRsrc_t *res = NULL;
LL_FOREACH( ace->resources, res)
{
if (NULL == res->href)
{
OIC_LOG_V(WARNING, TAG, "%s: wrong href of the resourse", __func__);
continue;
}
reslist_count++;
}
if(0 == reslist_count)
{
OIC_LOG_V(WARNING, TAG, "%s: there is no resourse", __func__);
return false;
}
acllist_count++;
}
if(0 == acllist_count)
{
OIC_LOG_V(WARNING, TAG, "%s: there is no acl", __func__);
return false;
}
return true;
}
OCStackResult OCCloudAclIndividualAclUpdate(void *ctx, OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
const char *aclId, const char *aclId,
const cloudAce_t *aces, const cloudAce_t *aces,
const char *cloudUri, const char *cloudUri,
OCCloudResponseCB callback) OCCloudResponseCB callback)
{ {
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 }; size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
char uri[MAX_URI_LENGTH] = { 0 }; char uri[MAX_URI_LENGTH] = { 0 };
...@@ -244,12 +291,25 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx, ...@@ -244,12 +291,25 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
OCRepPayload **helperPayload = NULL; OCRepPayload **helperPayload = NULL;
OCRepPayload **helperPayload2 = NULL; OCRepPayload **helperPayload2 = NULL;
cloudAce_t *ace = NULL;
size_t acllist_count = 0;
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aces, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aces, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId); if(!aceValidate((cloudAce_t*)aces))
{
OIC_LOG_V(WARNING, TAG, "%s: invalid aces", __func__);
return OC_STACK_INVALID_PARAM;
}
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL,
aclId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCRepPayload *payload = OCRepPayloadCreate(); OCRepPayload *payload = OCRepPayloadCreate();
if (!payload) if (!payload)
...@@ -258,7 +318,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx, ...@@ -258,7 +318,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
goto no_memory; goto no_memory;
} }
size_t acllist_count = 0; acllist_count = 0;
//code below duplicates LL_COUNT, implemented in newer version of utlist.h //code below duplicates LL_COUNT, implemented in newer version of utlist.h
{ {
cloudAce_t *ace = (cloudAce_t *)aces; cloudAce_t *ace = (cloudAce_t *)aces;
...@@ -269,7 +329,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx, ...@@ -269,7 +329,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
} }
} }
helperPayload = OICCalloc(acllist_count, sizeof(OCRepPayload *)); helperPayload = (OCRepPayload **)OICCalloc(acllist_count, sizeof(OCRepPayload *));
if (!helperPayload) if (!helperPayload)
{ {
OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload"); OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload");
...@@ -277,8 +337,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx, ...@@ -277,8 +337,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
} }
i = 0; i = 0;
cloudAce_t *ace = NULL; ace = NULL;
LL_FOREACH((cloudAce_t *)aces, ace) LL_FOREACH((cloudAce_t *)aces, ace)
{ {
OCRepPayload *acePayload = OCRepPayloadCreate(); OCRepPayload *acePayload = OCRepPayloadCreate();
...@@ -312,9 +371,10 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx, ...@@ -312,9 +371,10 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
} }
} }
helperPayload2 = OICCalloc(reslist_count, sizeof(OCRepPayload *)); helperPayload2 = (OCRepPayload **)OICCalloc(reslist_count, sizeof(OCRepPayload *));
if (!helperPayload2) if (!helperPayload2)
{ {
OIC_LOG_V(ERROR, TAG, "%s: Can't allocate memory", __func__);
goto no_memory; goto no_memory;
} }
...@@ -381,19 +441,32 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx, ...@@ -381,19 +441,32 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx,
{ {
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 }; size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
char uri[MAX_URI_LENGTH] = { 0 }; char uri[MAX_URI_LENGTH] = { 0 };
cloudAce_t *ace;
int i = 0, j = 0; int i = 0, j = 0;
OCRepPayload **helperPayload = NULL; OCRepPayload **helperPayload = NULL;
OCRepPayload **helperPayload2 = NULL; OCRepPayload **helperPayload2 = NULL;
size_t acllist_count;
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aceId, TAG, "NULL aceId", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aceId, TAG, "NULL aceId", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aces, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aces, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId, if(!aceValidate((cloudAce_t*)aces))
OC_RSRVD_ACE_ID, aceId); {
OIC_LOG_V(WARNING, TAG, "%s: invalid aces", __func__);
return OC_STACK_INVALID_PARAM;
}
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s?%s=%s", cloudUri,
OC_RSRVD_ACL_ID_URL, aclId,
OC_RSRVD_ACE_ID, aceId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCRepPayload *payload = OCRepPayloadCreate(); OCRepPayload *payload = OCRepPayloadCreate();
if (!payload) if (!payload)
...@@ -402,9 +475,9 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx, ...@@ -402,9 +475,9 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx,
goto no_memory; goto no_memory;
} }
size_t acllist_count = 1; acllist_count = 1;
helperPayload = OICCalloc(acllist_count, sizeof(OCRepPayload *)); helperPayload = (OCRepPayload **)OICCalloc(acllist_count, sizeof(OCRepPayload *));
if (!helperPayload) if (!helperPayload)
{ {
OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload"); OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload");
...@@ -412,7 +485,7 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx, ...@@ -412,7 +485,7 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx,
} }
i = 0; i = 0;
cloudAce_t *ace = NULL; ace = NULL;
LL_FOREACH((cloudAce_t *)aces, ace) LL_FOREACH((cloudAce_t *)aces, ace)
{ {
...@@ -447,7 +520,7 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx, ...@@ -447,7 +520,7 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx,
} }
} }
helperPayload2 = OICCalloc(reslist_count, sizeof(OCRepPayload *)); helperPayload2 = (OCRepPayload **)OICCalloc(reslist_count, sizeof(OCRepPayload *));
if (!helperPayload2) if (!helperPayload2)
{ {
goto no_memory; goto no_memory;
...@@ -519,7 +592,12 @@ OCStackResult OCCloudAclAcesDelete(void *ctx, ...@@ -519,7 +592,12 @@ OCStackResult OCCloudAclAcesDelete(void *ctx,
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId); if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL,
aclId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData; OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, NULL, NULL); fillCallbackData(&cbData, ctx, callback, NULL, NULL);
...@@ -529,10 +607,10 @@ OCStackResult OCCloudAclAcesDelete(void *ctx, ...@@ -529,10 +607,10 @@ OCStackResult OCCloudAclAcesDelete(void *ctx,
} }
OCStackResult OCCloudAclIndividualAceDelete(void *ctx, OCStackResult OCCloudAclIndividualAceDelete(void *ctx,
const char *aclId, const char *aclId,
const char *aceId, const char *aceId,
const char *cloudUri, const char *cloudUri,
OCCloudResponseCB callback) OCCloudResponseCB callback)
{ {
char uri[MAX_URI_LENGTH] = { 0 }; char uri[MAX_URI_LENGTH] = { 0 };
...@@ -540,8 +618,13 @@ OCStackResult OCCloudAclIndividualAceDelete(void *ctx, ...@@ -540,8 +618,13 @@ OCStackResult OCCloudAclIndividualAceDelete(void *ctx,
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aceId, TAG, "NULL aceId", OC_STACK_INVALID_PARAM); VERIFY_NON_NULL_RET(aceId, TAG, "NULL aceId", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId, if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s?%s=%s", cloudUri,
OC_RSRVD_ACE_ID, aceId); OC_RSRVD_ACL_ID_URL, aclId,
OC_RSRVD_ACE_ID, aceId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData; OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, NULL, NULL); fillCallbackData(&cbData, ctx, callback, NULL, NULL);
......
...@@ -48,6 +48,8 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char ...@@ -48,6 +48,8 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 }; size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
OCRepPayload **helperPayload = NULL; OCRepPayload **helperPayload = NULL;
size_t i = 0; size_t i = 0;
stringArray_t *gidlist = NULL;
stringArray_t *midlist = NULL;
if (!OCRepPayloadGetPropObjectArray(payload, name, &helperPayload, dimensions)) if (!OCRepPayloadGetPropObjectArray(payload, name, &helperPayload, dimensions))
{ {
...@@ -56,21 +58,26 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char ...@@ -56,21 +58,26 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char
} }
size_t count = calcDimTotal(dimensions); size_t count = calcDimTotal(dimensions);
if (0 == count)
{
OIC_LOG(ERROR, TAG, "zero list len");
goto exit;
}
stringArray_t *gidlist = &out->gidlist; gidlist = &out->gidlist;
stringArray_t *midlist = &out->midlist; midlist = &out->midlist;
gidlist->length = count; gidlist->length = count;
midlist->length = count; midlist->length = count;
gidlist->array = OICCalloc(gidlist->length, sizeof(char *)); gidlist->array = (char**)OICCalloc(gidlist->length, sizeof(char *));
if (NULL == gidlist->array) if (NULL == gidlist->array)
{ {
OIC_LOG(ERROR, TAG, "Can't allocate gidlist->array"); OIC_LOG(ERROR, TAG, "Can't allocate gidlist->array");
goto exit; goto exit;
} }
midlist->array = OICCalloc(midlist->length, sizeof(char *)); midlist->array = (char**)OICCalloc(midlist->length, sizeof(char *));
if (NULL == midlist->array) if (NULL == midlist->array)
{ {
OIC_LOG(ERROR, TAG, "Can't allocate midlist->array"); OIC_LOG(ERROR, TAG, "Can't allocate midlist->array");
...@@ -83,14 +90,14 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char ...@@ -83,14 +90,14 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char
if (!OCRepPayloadGetPropString(gidPayload, OC_RSRVD_GROUP_ID, &gidlist->array[i])) if (!OCRepPayloadGetPropString(gidPayload, OC_RSRVD_GROUP_ID, &gidlist->array[i]))
{ {
OIC_LOG_V(ERROR, TAG, "Can't get: %s", OC_RSRVD_GROUP_ID); OIC_LOG_V(ERROR, TAG, "Can't get group id: %s", OC_RSRVD_GROUP_ID);
result = OC_STACK_MALFORMED_RESPONSE; result = OC_STACK_MALFORMED_RESPONSE;
goto exit; goto exit;
} }
if (!OCRepPayloadGetPropString(gidPayload, OC_RSRVD_MEMBER_ID, &midlist->array[i])) if (!OCRepPayloadGetPropString(gidPayload, OC_RSRVD_MEMBER_ID, &midlist->array[i]))
{ {
OIC_LOG_V(ERROR, TAG, "Can't get: %s", OC_RSRVD_MEMBER_ID); OIC_LOG_V(ERROR, TAG, "Can't get member id: %s", OC_RSRVD_MEMBER_ID);
result = OC_STACK_MALFORMED_RESPONSE; result = OC_STACK_MALFORMED_RESPONSE;
goto exit; goto exit;
} }
...@@ -128,13 +135,16 @@ static OCStackResult handleAclGetInvitationResponse(void *ctx, void **data, ...@@ -128,13 +135,16 @@ static OCStackResult handleAclGetInvitationResponse(void *ctx, void **data,
OC_UNUSED(ctx); OC_UNUSED(ctx);
OCStackResult result = OC_STACK_OK; OCStackResult result = OC_STACK_OK;
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
if (NULL == response->payload) if (NULL == response->payload)
{ {
OIC_LOG(ERROR, TAG, "Receive NULL payload"); OIC_LOG(ERROR, TAG, "Receive NULL payload");
return OC_STACK_INVALID_PARAM; return OC_STACK_INVALID_PARAM;
} }
inviteResponse_t *answer = OICCalloc(1, sizeof(inviteResponse_t)); inviteResponse_t *answer = (inviteResponse_t*)OICCalloc(1, sizeof(inviteResponse_t));
if (NULL == answer)