- Patch #1 : Init patch
- Patch #2 : Modify file permission
- Patch #3 : Update doxmresource.c
- Patch #4 : fix defects
- Patch #5 : Apply the review comment of Mr. Cho
- Patch #6 : Apply the review comment of Mr. Chul Lee.
Change-Id: I7c1ffb65bed604adbee60ee55456f230b83a759c
Signed-off-by: js126.lee <js126.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5653
Reviewed-by: Kyungsun Cho <goodsun.cho@samsung.com>
Reviewed-by: dongik Lee <dongik.lee@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
Tested-by: Randeep Singh <randeep.s@samsung.com>
(cherry picked from commit
61853f8bce9f038b91fd1aa1127c990469b58c24)
Reviewed-on: https://gerrit.iotivity.org/gerrit/5687
14 files changed:
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
- acl->resourcesLen = cJSON_GetArraySize(jsonObj);
+ acl->resourcesLen = (size_t)cJSON_GetArraySize(jsonObj);
VERIFY_SUCCESS(TAG, acl->resourcesLen > 0, ERROR);
acl->resources = (char**)OICCalloc(acl->resourcesLen, sizeof(char*));
VERIFY_NON_NULL(TAG, (acl->resources), ERROR);
VERIFY_SUCCESS(TAG, acl->resourcesLen > 0, ERROR);
acl->resources = (char**)OICCalloc(acl->resourcesLen, sizeof(char*));
VERIFY_NON_NULL(TAG, (acl->resources), ERROR);
{
VERIFY_SUCCESS(TAG, cJSON_Array == jsonPeriodObj->type,
ERROR);
{
VERIFY_SUCCESS(TAG, cJSON_Array == jsonPeriodObj->type,
ERROR);
- acl->prdRecrLen = cJSON_GetArraySize(jsonPeriodObj);
+ acl->prdRecrLen = (size_t)cJSON_GetArraySize(jsonPeriodObj);
if(acl->prdRecrLen > 0)
{
acl->periods = (char**)OICCalloc(acl->prdRecrLen,
if(acl->prdRecrLen > 0)
{
acl->periods = (char**)OICCalloc(acl->prdRecrLen,
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
- acl->ownersLen = cJSON_GetArraySize(jsonObj);
+ acl->ownersLen = (size_t)cJSON_GetArraySize(jsonObj);
VERIFY_SUCCESS(TAG, acl->ownersLen > 0, ERROR);
acl->owners = (OicUuid_t*)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, (acl->owners), ERROR);
VERIFY_SUCCESS(TAG, acl->ownersLen > 0, ERROR);
acl->owners = (OicUuid_t*)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, (acl->owners), ERROR);
OICFree(acl->resources[resPos]);
acl->resources[resPos] = NULL;
acl->resourcesLen -= 1;
OICFree(acl->resources[resPos]);
acl->resources[resPos] = NULL;
acl->resourcesLen -= 1;
- for(i = resPos; i < acl->resourcesLen; i++)
+ for(i = (size_t)resPos; i < acl->resourcesLen; i++)
{
acl->resources[i] = acl->resources[i+1];
}
{
acl->resources[i] = acl->resources[i+1];
}
OicSecAmacl_t *amaclTmp1 = NULL, *amaclTmp2 = NULL;
LL_FOREACH_SAFE(amacl, amaclTmp1, amaclTmp2)
{
OicSecAmacl_t *amaclTmp1 = NULL, *amaclTmp2 = NULL;
LL_FOREACH_SAFE(amacl, amaclTmp1, amaclTmp2)
{
LL_DELETE(amacl, amaclTmp1);
// Clean Resources
LL_DELETE(amacl, amaclTmp1);
// Clean Resources
- for (i = 0; i < amaclTmp1->resourcesLen; i++)
+ for (size_t i = 0; i < amaclTmp1->resourcesLen; i++)
{
OICFree(amaclTmp1->resources[i]);
}
{
OICFree(amaclTmp1->resources[i]);
}
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
- amacl->resourcesLen = cJSON_GetArraySize(jsonObj);
+ amacl->resourcesLen = (size_t)cJSON_GetArraySize(jsonObj);
VERIFY_SUCCESS(TAG, amacl->resourcesLen > 0, ERROR);
amacl->resources = (char**)OICCalloc(amacl->resourcesLen, sizeof(char*));
VERIFY_NON_NULL(TAG, (amacl->resources), ERROR);
VERIFY_SUCCESS(TAG, amacl->resourcesLen > 0, ERROR);
amacl->resources = (char**)OICCalloc(amacl->resourcesLen, sizeof(char*));
VERIFY_NON_NULL(TAG, (amacl->resources), ERROR);
if(OC_STACK_OK == DiscoverAmsService(context))
{
context->retVal = ACCESS_WAITING_FOR_AMS;
if(OC_STACK_OK == DiscoverAmsService(context))
{
context->retVal = ACCESS_WAITING_FOR_AMS;
+ OIC_LOG_V(INFO, TAG, "Leaving %s(WAITING_FOR_AMS)", __func__);
context->state = AWAITING_AMS_RESPONSE;
}
else
context->state = AWAITING_AMS_RESPONSE;
}
else
{
OIC_LOG_V(INFO, TAG, "Leaving %s(context is NULL)", __func__);
}
{
OIC_LOG_V(INFO, TAG, "Leaving %s(context is NULL)", __func__);
}
-
- if(ACCESS_WAITING_FOR_AMS == context->retVal )
- {
- OIC_LOG_V(INFO, TAG, "Leaving %s(WAITING_FOR_AMS)", __func__);
- }
B64Result b64Encode(const uint8_t* in, const size_t inLen,
char* outBuf, const size_t outBufSize, uint32_t* outLen)
{
B64Result b64Encode(const uint8_t* in, const size_t inLen,
char* outBuf, const size_t outBufSize, uint32_t* outLen)
{
- uint32_t i;
- uint32_t minBufSize;
+ size_t i;
+ size_t minBufSize;
if (NULL == in || 0 == inLen || NULL == outBuf || NULL == outLen )
{
if (NULL == in || 0 == inLen || NULL == outBuf || NULL == outLen )
{
jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OXM_TYPE_NAME);
if ((jsonObj) && (cJSON_Array == jsonObj->type))
{
jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OXM_TYPE_NAME);
if ((jsonObj) && (cJSON_Array == jsonObj->type))
{
- doxm->oxmTypeLen = cJSON_GetArraySize(jsonObj);
+ doxm->oxmTypeLen = (size_t)cJSON_GetArraySize(jsonObj);
VERIFY_SUCCESS(TAG, doxm->oxmTypeLen > 0, ERROR);
doxm->oxmType = (OicUrn_t *)OICCalloc(doxm->oxmTypeLen, sizeof(char *));
VERIFY_SUCCESS(TAG, doxm->oxmTypeLen > 0, ERROR);
doxm->oxmType = (OicUrn_t *)OICCalloc(doxm->oxmTypeLen, sizeof(char *));
jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OXM_NAME);
if (jsonObj && cJSON_Array == jsonObj->type)
{
jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OXM_NAME);
if (jsonObj && cJSON_Array == jsonObj->type)
{
- doxm->oxmLen = cJSON_GetArraySize(jsonObj);
+ doxm->oxmLen = (size_t)cJSON_GetArraySize(jsonObj);
VERIFY_SUCCESS(TAG, doxm->oxmLen > 0, ERROR);
doxm->oxm = (OicSecOxm_t*)OICCalloc(doxm->oxmLen, sizeof(OicSecOxm_t));
VERIFY_SUCCESS(TAG, doxm->oxmLen > 0, ERROR);
doxm->oxm = (OicSecOxm_t*)OICCalloc(doxm->oxmLen, sizeof(OicSecOxm_t));
* Disable anonymous ECDH cipher in tinyDTLS since device is now
* in owned state.
*/
* Disable anonymous ECDH cipher in tinyDTLS since device is now
* in owned state.
*/
- CAEnableAnonECDHCipherSuite(false);
+ CAResult_t caRes = CA_STATUS_OK;
+ caRes = CAEnableAnonECDHCipherSuite(false);
+ VERIFY_SUCCESS(TAG, caRes == CA_STATUS_OK, ERROR);
+ OIC_LOG(INFO, TAG, "ECDH_ANON CipherSuite is DISABLED");
+
#ifdef __WITH_X509__
#define TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 0xC0AE
CASelectCipherSuite(TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8);
#ifdef __WITH_X509__
#define TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 0xC0AE
CASelectCipherSuite(TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
if (cJSON_Array == jsonObj->type)
{
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
if (cJSON_Array == jsonObj->type)
{
- pstat->smLen = cJSON_GetArraySize(jsonObj);
+ pstat->smLen = (size_t)cJSON_GetArraySize(jsonObj);
size_t idxx = 0;
VERIFY_SUCCESS(TAG, pstat->smLen != 0, ERROR);
pstat->sm = (OicSecDpom_t*)OICCalloc(pstat->smLen, sizeof(OicSecDpom_t));
size_t idxx = 0;
VERIFY_SUCCESS(TAG, pstat->smLen != 0, ERROR);
pstat->sm = (OicSecDpom_t*)OICCalloc(pstat->smLen, sizeof(OicSecDpom_t));
// TODO: temporarily returning OC_STACK_OK every time until default
// behavior (for when SVR DB is missing) is settled.
InitSecureResources();
// TODO: temporarily returning OC_STACK_OK every time until default
// behavior (for when SVR DB is missing) is settled.
InitSecureResources();
+ OCStackResult ret = OC_STACK_OK;
#if defined(__WITH_DTLS__)
#if defined(__WITH_DTLS__)
- CARegisterDTLSCredentialsHandler(GetDtlsPskCredentials);
+ if(CA_STATUS_OK != CARegisterDTLSCredentialsHandler(GetDtlsPskCredentials))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to revert DTLS credential handler.");
+ ret = OC_STACK_ERROR;
+ }
+
#endif // (__WITH_DTLS__)
#if defined(__WITH_X509__)
CARegisterDTLSX509CredentialsHandler(GetDtlsX509Credentials);
CARegisterDTLSCrlHandler(GetDerCrl);
#endif // (__WITH_X509__)
#endif // (__WITH_DTLS__)
#if defined(__WITH_X509__)
CARegisterDTLSX509CredentialsHandler(GetDtlsX509Credentials);
CARegisterDTLSCrlHandler(GetDerCrl);
#endif // (__WITH_X509__)
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
- *numUuids = cJSON_GetArraySize(jsonObj);
+ *numUuids = (size_t)cJSON_GetArraySize(jsonObj);
VERIFY_SUCCESS(TAG, *numUuids > 0, ERROR);
*uuids = (OicUuid_t*)OICCalloc(*numUuids, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, *uuids, ERROR);
VERIFY_SUCCESS(TAG, *numUuids > 0, ERROR);
*uuids = (OicUuid_t*)OICCalloc(*numUuids, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, *uuids, ERROR);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Array == jsonObj->type, ERROR);
- svc->ownersLen = cJSON_GetArraySize(jsonObj);
+ svc->ownersLen = (size_t)cJSON_GetArraySize(jsonObj);
VERIFY_SUCCESS(TAG, svc->ownersLen > 0, ERROR);
svc->owners = (OicUuid_t*)OICCalloc(svc->ownersLen, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, (svc->owners), ERROR);
VERIFY_SUCCESS(TAG, svc->ownersLen > 0, ERROR);
svc->owners = (OicUuid_t*)OICCalloc(svc->ownersLen, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, (svc->owners), ERROR);
{
OCStackResult ret = OC_STACK_ERROR;
memcpy(acl->subject.id, "2222222222222222", sizeof(acl->subject.id));
{
OCStackResult ret = OC_STACK_ERROR;
memcpy(acl->subject.id, "2222222222222222", sizeof(acl->subject.id));
- acl->resourcesLen = numRsrc;
+ acl->resourcesLen = (size_t)numRsrc;
acl->resources = (char**)OICCalloc(acl->resourcesLen, sizeof(char*));
VERIFY_NON_NULL(TAG, acl->resources, ERROR);
acl->resources[0] = (char*)OICMalloc(strlen("/a/led")+1);
acl->resources = (char**)OICCalloc(acl->resourcesLen, sizeof(char*));
VERIFY_NON_NULL(TAG, acl->resources, ERROR);
acl->resources[0] = (char*)OICMalloc(strlen("/a/led")+1);
// Verify if SRM contains ACE for the subject with two resources
savePtr = NULL;
subjectAcl1 = GetACLResourceData(&acl.subject, &savePtr);
// Verify if SRM contains ACE for the subject with two resources
savePtr = NULL;
subjectAcl1 = GetACLResourceData(&acl.subject, &savePtr);
- EXPECT_TRUE(NULL != subjectAcl1);
+ VERIFY_NON_NULL(TAG, subjectAcl1, ERROR);
EXPECT_TRUE(subjectAcl1->resourcesLen == 2);
// Create Entity Handler DELETE request
EXPECT_TRUE(subjectAcl1->resourcesLen == 2);
// Create Entity Handler DELETE request
// Verify if SRM contains ACL for the subject but only with one resource
savePtr = NULL;
subjectAcl2 = GetACLResourceData(&acl.subject, &savePtr);
// Verify if SRM contains ACL for the subject but only with one resource
savePtr = NULL;
subjectAcl2 = GetACLResourceData(&acl.subject, &savePtr);
- EXPECT_TRUE(NULL != subjectAcl2);
+ VERIFY_NON_NULL(TAG, subjectAcl2, ERROR);
EXPECT_TRUE(subjectAcl2->resourcesLen == 1);
exit:
EXPECT_TRUE(subjectAcl2->resourcesLen == 1);
exit:
// Tests for base64 decode function
TEST(B64DeodeTest, InvalidInputForDecoding)
{
// Tests for base64 decode function
TEST(B64DeodeTest, InvalidInputForDecoding)
{
+ uint8_t buf[128] = {0,};
uint32_t outputLength;
uint32_t i=0;
uint32_t outputLength;
uint32_t i=0;
cred->credType = SYMMETRIC_PAIR_WISE_KEY;
cred->privateData.data = (char *)OICCalloc(1, strlen("My private Key11") + 1);
VERIFY_NON_NULL(TAG, cred->privateData.data, ERROR);
cred->credType = SYMMETRIC_PAIR_WISE_KEY;
cred->privateData.data = (char *)OICCalloc(1, strlen("My private Key11") + 1);
VERIFY_NON_NULL(TAG, cred->privateData.data, ERROR);
- strcpy(cred->privateData.data, "My private Key11");
+ OICStrcpy(cred->privateData.data, strlen("My private Key11")+1,"My private Key11");
cred->ownersLen = 1;
cred->owners = (OicUuid_t*)OICCalloc(cred->ownersLen, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, cred->owners, ERROR);
cred->ownersLen = 1;
cred->owners = (OicUuid_t*)OICCalloc(cred->ownersLen, sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, cred->owners, ERROR);
- strcpy(doxm->oxmType[0], OXM_JUST_WORKS);
+ OICStrcpy(doxm->oxmType[0], strlen(OXM_JUST_WORKS) + 1, OXM_JUST_WORKS);
doxm->oxmLen = 1;
doxm->oxm = (OicSecOxm_t *)OICCalloc(doxm->oxmLen, sizeof(OicSecOxm_t));
if(!doxm->oxm)
doxm->oxmLen = 1;
doxm->oxm = (OicSecOxm_t *)OICCalloc(doxm->oxmLen, sizeof(OicSecOxm_t));
if(!doxm->oxm)
doxm->owned = true;
//TODO: Need more clarification on deviceIDFormat field type.
//doxm.deviceIDFormat = URN;
doxm->owned = true;
//TODO: Need more clarification on deviceIDFormat field type.
//doxm.deviceIDFormat = URN;
- strcpy((char *) doxm->deviceID.id, "deviceId");
- strcpy((char *)doxm->owner.id, "ownersId");
+ OICStrcpy((char *) doxm->deviceID.id, strlen("deviceId") + 1, "deviceId");
+ OICStrcpy((char *) doxm->owner.id, strlen("ownersId") + 1, "ownersId");
OIC_LOG_V(INFO, TAG, "recur->until.tm_mon = %d", recur->until.tm_mon);
OIC_LOG_V(INFO, TAG, "recur->until.tm_mday = %d", recur->until.tm_mday);
OIC_LOG_V(INFO, TAG, "recur->until.tm_mon = %d", recur->until.tm_mon);
OIC_LOG_V(INFO, TAG, "recur->until.tm_mday = %d", recur->until.tm_mday);
- if(recur->byDay & SUNDAY)
+ if(0 != (recur->byDay & SUNDAY))
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Sunday");
}
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Sunday");
}
- if(recur->byDay & MONDAY)
+ if(0 != (recur->byDay & MONDAY))
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Monday");
}
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Monday");
}
- if(recur->byDay & TUESDAY)
+ if(0 != (recur->byDay & TUESDAY))
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Tuesday");
}
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Tuesday");
}
- if(recur->byDay & WEDNESDAY)
+ if(0 != (recur->byDay & WEDNESDAY))
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Wednesday");
}
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Wednesday");
}
- if(recur->byDay & THURSDAY)
+ if(0 != (recur->byDay & THURSDAY))
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Thursday");
}
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Thursday");
}
- if(recur->byDay & FRIDAY)
+ if(0 != (recur->byDay & FRIDAY))
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Friday");
}
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Friday");
}
- if(recur->byDay & SATURDAY)
+ if(0 != (recur->byDay & SATURDAY))
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Saturday");
}
{
OIC_LOG_V(INFO, TAG, "recur->byDay = %s", "Saturday");
}