From b133782529dcdbf8092b410a9e9b6cfc561c1eaa Mon Sep 17 00:00:00 2001 From: Vitalii Irkha Date: Fri, 22 Nov 2019 11:46:14 +0200 Subject: QB_linux_SECURED build failed Fixed issues for SVR DB Validity APIs https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/49420e214b01e2656b123c0bae3fad245bec14f9 (cherry-picked from 49420e214b01e2656b123c0bae3fad245bec14f9) Change-Id: I6c1826f501230414a8c04596ede23ff01a1651d9 Signed-off-by: Vitalii Irkha Signed-off-by: DoHyun Pyun --- .../csdk/security/include/internal/psinterface.h | 2 +- resource/csdk/security/include/srmutility.h | 27 +++++++++++++++++++ resource/csdk/security/src/psinterface.c | 31 +++++++++++----------- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/resource/csdk/security/include/internal/psinterface.h b/resource/csdk/security/include/internal/psinterface.h index 6848bfe4d..0d7b1799d 100644 --- a/resource/csdk/security/include/internal/psinterface.h +++ b/resource/csdk/security/include/internal/psinterface.h @@ -171,7 +171,7 @@ OCStackResult setSecurePSI(const unsigned char *key, const OCPersistentStorage * * * @return pointer on resetSVRDB structure for manipulating with callback */ -resetSVRDBCB_t* const GetResetSVRDBCB(void); +resetSVRDBCB_t* GetResetSVRDBCB(void); /** * API to validate data in SVR DB. diff --git a/resource/csdk/security/include/srmutility.h b/resource/csdk/security/include/srmutility.h index 22936b730..a48d322b4 100644 --- a/resource/csdk/security/include/srmutility.h +++ b/resource/csdk/security/include/srmutility.h @@ -199,4 +199,31 @@ bool IsNilUuid(const OicUuid_t *uuid); } #endif // __cplusplus +/** + * cbor default init + */ +#ifndef OC_DEFAULT_CBOR_VALUE +# if (__STDC_VERSION__ >= 199901L) +# define OC_DEFAULT_CBOR_VALUE {.parser = NULL, .ptr = NULL, .remaining = 0, .extra = 0, .type = 0, .flags = 0} +# else +# define OC_DEFAULT_CBOR_VALUE {NULL, NULL, 0, 0, 0, 0} +# endif +#endif + +#ifndef OC_DEFAULT_CBOR_PARSER +# if (__STDC_VERSION__ >= 199901L) +# define OC_DEFAULT_CBOR_PARSER {.end = NULL, .flags = 0} +# else +# define OC_DEFAULT_CBOR_PARSER {NULL, 0} +# endif +#endif + +#ifndef OC_DEFAULT_OICUUID +# if (__STDC_VERSION__ >= 199901L) +# define OC_DEFAULT_OICUUID {.id= { 0 } } +# else +# define OC_DEFAULT_OICUUID {{ 0 }} +# endif +#endif + #endif //IOTVT_SRM_UTILITY_H diff --git a/resource/csdk/security/src/psinterface.c b/resource/csdk/security/src/psinterface.c index 351492044..0964232ce 100644 --- a/resource/csdk/security/src/psinterface.c +++ b/resource/csdk/security/src/psinterface.c @@ -66,7 +66,7 @@ static SVRDBValidStatus_t g_svrdbValidStatus = SVRDB_NOT_CHECKED; static resetSVRDBCB_t g_resetSVRDBCB = {0}; -resetSVRDBCB_t* const GetResetSVRDBCB(void) +resetSVRDBCB_t* GetResetSVRDBCB(void) { return &g_resetSVRDBCB; } @@ -1260,7 +1260,16 @@ OCStackResult CheckSVRDBValidity(void) OIC_LOG_V(DEBUG, TAG, "In %s", __func__); OCStackResult res = OC_STACK_ERROR; - OicUuid_t emptyUuid = {.id={0}}; + OicUuid_t emptyUuid = OC_DEFAULT_OICUUID; + OicUuid_t devOwnerUuid = OC_DEFAULT_OICUUID; + OicUuid_t devRownerUuid = OC_DEFAULT_OICUUID; + OicUuid_t resRowneruuid = OC_DEFAULT_OICUUID; + bool isDevOwnerUuidEmpty = false; + bool isDevRownerUuidEmpty = false; + bool isPstatRownerUuidEmpty = false; + bool isAclRownerUuidEmpty = false; + bool isCredRownerUuidEmpty = false; + OicSecDpm_t cm = NORMAL; bool isOwned = false; res = GetDoxmIsOwned(&isOwned); @@ -1271,16 +1280,7 @@ OCStackResult CheckSVRDBValidity(void) goto exit; } - OicUuid_t devOwnerUuid = {.id={0}}; - OicUuid_t devRownerUuid = {.id={0}}; - OicUuid_t resRowneruuid = {.id={0}}; - bool isDevOwnerUuidEmpty = false; - bool isDevRownerUuidEmpty = false; - bool isPstatRownerUuidEmpty = false; - bool isAclRownerUuidEmpty = false; - bool isCredRownerUuidEmpty = false; - - if(OC_STACK_OK != GetDoxmDevOwnerId(&devOwnerUuid) | + if(OC_STACK_OK != GetDoxmDevOwnerId(&devOwnerUuid) || OC_STACK_OK != GetDoxmRownerId(&devRownerUuid)) { res = OC_STACK_ERROR; @@ -1320,7 +1320,6 @@ OCStackResult CheckSVRDBValidity(void) isPstatRownerUuidEmpty = false; } - OicSecDpm_t cm = NORMAL; VERIFY_SUCCESS(TAG, OC_STACK_OK == GetPstatCm(&cm), ERROR); if (OC_STACK_OK != GetAclRownerId(&resRowneruuid)) @@ -1490,10 +1489,10 @@ bool isResetPFExist(void) { ocRes = OC_STACK_ERROR; { - CborParser parser; - CborValue cbor; + CborParser parser = OC_DEFAULT_CBOR_PARSER; + CborValue cbor = OC_DEFAULT_CBOR_VALUE; cbor_parser_init(dbData, dbSize, 0, &parser, &cbor); - CborValue curVal = {0}; + CborValue curVal = OC_DEFAULT_CBOR_VALUE; CborError cborFindResult = CborNoError; cborFindResult = cbor_value_map_find_value(&cbor, OIC_JSON_RESET_PF_NAME, &curVal); -- cgit v1.2.3