Fixed defects reported by svace in SRM
authorjs126.lee <js126.lee@samsung.com>
Thu, 10 Mar 2016 02:03:02 +0000 (11:03 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Thu, 10 Mar 2016 13:05:41 +0000 (13:05 +0000)
- 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:
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/amaclresource.c
resource/csdk/security/src/amsmgr.c
resource/csdk/security/src/base64.c
resource/csdk/security/src/doxmresource.c
resource/csdk/security/src/pstatresource.c
resource/csdk/security/src/secureresourcemanager.c
resource/csdk/security/src/srmutility.c
resource/csdk/security/src/svcresource.c
resource/csdk/security/unittest/aclresourcetest.cpp
resource/csdk/security/unittest/base64tests.cpp
resource/csdk/security/unittest/credentialresource.cpp
resource/csdk/security/unittest/doxmresource.cpp
resource/csdk/security/unittest/iotvticalendartest.cpp

index f6d137e..3a47b08 100644 (file)
@@ -282,7 +282,7 @@ OicSecAcl_t * JSONToAclBin(const char * jsonStr)
             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);
@@ -313,7 +313,7 @@ OicSecAcl_t * JSONToAclBin(const char * jsonStr)
             {
                 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,
@@ -368,7 +368,7 @@ OicSecAcl_t * JSONToAclBin(const char * jsonStr)
             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);
@@ -497,7 +497,7 @@ static OCStackResult RemoveACE(const OicUuid_t * subject,
                         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];
                         }
index de7e990..63aef6a 100644 (file)
@@ -48,12 +48,10 @@ void DeleteAmaclList(OicSecAmacl_t* amacl)
         OicSecAmacl_t *amaclTmp1 = NULL, *amaclTmp2 = NULL;
         LL_FOREACH_SAFE(amacl, amaclTmp1, amaclTmp2)
         {
         OicSecAmacl_t *amaclTmp1 = NULL, *amaclTmp2 = NULL;
         LL_FOREACH_SAFE(amacl, amaclTmp1, amaclTmp2)
         {
-            unsigned int i = 0;
-
             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]);
             }
@@ -206,7 +204,7 @@ OicSecAmacl_t * JSONToAmaclBin(const char * jsonStr)
             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);
index f9396e6..c9be755 100644 (file)
@@ -414,6 +414,7 @@ void ProcessAMSRequest(PEContext_t *context)
                 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
@@ -427,9 +428,4 @@ void ProcessAMSRequest(PEContext_t *context)
     {
         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__);
-    }
 }
 }
index 3b20cf5..2a1ac98 100644 (file)
@@ -93,8 +93,8 @@ static B64Result b64EncodeBlk(const uint8_t* in, char* out, uint32_t len)
 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 )
     {
index 30d3d97..3fe5ce8 100644 (file)
@@ -200,7 +200,7 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr)
     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 *));
@@ -222,7 +222,7 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr)
     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));
@@ -522,7 +522,11 @@ static OCEntityHandlerResult HandleDoxmPutRequest (const OCEntityHandlerRequest
                      * 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);
index 4bada31..d3ecc27 100644 (file)
@@ -168,7 +168,7 @@ OicSecPstat_t * JSONToPstatBin(const char * jsonStr)
     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));
index 555d900..e2bec48 100644 (file)
@@ -338,16 +338,21 @@ OCStackResult SRMInitSecureResources()
     // 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__)
 
-    return OC_STACK_OK;
+    return ret;
 }
 
 /**
 }
 
 /**
index 9562664..8f8cc7f 100644 (file)
@@ -98,7 +98,7 @@ OCStackResult AddUuidArray(cJSON* jsonRoot, const char* arrayItem,
     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);
index 4456b38..bb55450 100644 (file)
@@ -190,7 +190,7 @@ OicSecSvc_t * JSONToSvcBin(const char * jsonStr)
             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);
index 08e7d26..74fb3c5 100644 (file)
@@ -210,7 +210,7 @@ static OCStackResult  populateAcl(OicSecAcl_t *acl,  int numRsrc)
 {
     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);
@@ -322,7 +322,7 @@ TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
     // 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
@@ -337,7 +337,7 @@ TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
     // 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:
index 4cce483..68e30e2 100644 (file)
@@ -186,7 +186,7 @@ TEST(B64DeodeTest, ValidInputForDecoding)
 // Tests for base64 decode function
 TEST(B64DeodeTest, InvalidInputForDecoding)
 {
 // Tests for base64 decode function
 TEST(B64DeodeTest, InvalidInputForDecoding)
 {
-    uint8_t buf[128];
+    uint8_t buf[128] = {0,};
     uint32_t outputLength;
     uint32_t i=0;
 
     uint32_t outputLength;
     uint32_t i=0;
 
index ee342ce..dd62f15 100644 (file)
@@ -72,7 +72,7 @@ OicSecCred_t * getCredList()
     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);
index 1e15a37..f303030 100644 (file)
@@ -71,7 +71,7 @@ OicSecDoxm_t * getBinDoxm()
         return NULL;
     }
 
         return NULL;
     }
 
-    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)
@@ -88,8 +88,8 @@ OicSecDoxm_t * getBinDoxm()
     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");
     return doxm;
 }
 
     return doxm;
 }
 
index 7a4c659..6c1c20d 100644 (file)
@@ -55,31 +55,31 @@ static void printRecur(IotvtICalRecur_t *recur)
     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");
     }