From e2860ed5c9acbafdee846556ee2db5ecad91d9a1 Mon Sep 17 00:00:00 2001 From: lsq Date: Sat, 14 May 2022 09:48:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lsq Change-Id: I47aa237f85424f7436132d0d89db420edf26c7b7 --- interfaces/innerkits/nativetoken/include/nativetoken.h | 2 +- interfaces/innerkits/nativetoken/src/nativetoken.c | 2 +- interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c | 4 ++-- .../nativetoken/test/unittest/src/nativetoken_kit_test.cpp | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/nativetoken/include/nativetoken.h b/interfaces/innerkits/nativetoken/include/nativetoken.h index e67f116be..dc71d3888 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 6d70d2a88..d426d9d4b 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 802ceaee6..7921b36ce 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 df7db9eca..f13cf2b45 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; } -- Gitee