diff --git a/interfaces/innerkits/nativetoken/include/nativetoken.h b/interfaces/innerkits/nativetoken/include/nativetoken.h index e67f116be1c9b0aa4e3c66e4a6e10d69b855e908..dc71d3888e53901c094f0b34747fc38c60d15294 100644 --- a/interfaces/innerkits/nativetoken/include/nativetoken.h +++ b/interfaces/innerkits/nativetoken/include/nativetoken.h @@ -95,7 +95,7 @@ typedef struct TokenList { } NativeTokenList; typedef struct StrArrayAttribute { - uint32_t maxStrNum; + int32_t maxStrNum; uint32_t maxStrLen; const char *strKey; } StrArrayAttr; diff --git a/interfaces/innerkits/nativetoken/src/nativetoken.c b/interfaces/innerkits/nativetoken/src/nativetoken.c index 6d70d2a8853507ca4ba439c4f2a6550530d48fc7..d426d9d4b2e18b826625464d1d22a2647d530c67 100644 --- a/interfaces/innerkits/nativetoken/src/nativetoken.c +++ b/interfaces/innerkits/nativetoken/src/nativetoken.c @@ -80,7 +80,7 @@ int32_t GetFileBuff(const char *cfg, char **retBuff) static void StrAttrSet(StrArrayAttr *attr, uint32_t maxStrLen, int32_t maxStrNum, const char *strKey) { attr->maxStrLen = maxStrLen; - attr->maxStrNum = maxStrLen; + attr->maxStrNum = maxStrNum; attr->strKey = strKey; } diff --git a/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c b/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c index 802ceaee667fbe3f0446888ffe2d5e9a1013b637..7921b36cea88008651fa5a11f3d7f25ea0021c61 100644 --- a/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c +++ b/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c @@ -76,14 +76,14 @@ uint32_t GetAplFromJson(cJSON *cjsonItem, NativeTokenList *tokenNode) uint32_t GetInfoArrFromJson(cJSON *cjsonItem, char *strArr[], int32_t *strNum, StrArrayAttr *attr) { cJSON *strArrJson = cJSON_GetObjectItem(cjsonItem, attr->strKey); - uint32_t size = (uint32_t)cJSON_GetArraySize(strArrJson); + int32_t size = cJSON_GetArraySize(strArrJson); if (size > attr->maxStrNum) { AT_LOG_ERROR("[ATLIB-%s]:size = %d is invalid.", __func__, size); return ATRET_FAILED; } *strNum = size; - for (uint32_t i = 0; i < size; i++) { + for (int32_t i = 0; i < size; i++) { cJSON *item = cJSON_GetArrayItem(strArrJson, i); if ((item == NULL) || (!cJSON_IsString(item)) || (item->valuestring == NULL)) { AT_LOG_ERROR("[ATLIB-%s]:cJSON_GetArrayItem failed.", __func__); diff --git a/interfaces/innerkits/nativetoken/test/unittest/src/nativetoken_kit_test.cpp b/interfaces/innerkits/nativetoken/test/unittest/src/nativetoken_kit_test.cpp index df7db9eca56958498f610d83baf8385de6a1a22e..f13cf2b45be685c28eabb7b52a3f4ae35f4b2ecf 100644 --- a/interfaces/innerkits/nativetoken/test/unittest/src/nativetoken_kit_test.cpp +++ b/interfaces/innerkits/nativetoken/test/unittest/src/nativetoken_kit_test.cpp @@ -70,6 +70,7 @@ int32_t Start(const char *processName) tokenId = GetAccessTokenId(&infoInstance); delete[] dcaps; delete[] perms; + delete[] acls; return tokenId; }