From 56e110943926c768b3ec71e0ddd036cb0ed1ca76 Mon Sep 17 00:00:00 2001 From: xia-bubai Date: Mon, 14 Apr 2025 22:18:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4init=20=E8=AF=BBnativetoken.j?= =?UTF-8?q?son=E6=97=B6=E6=9D=83=E9=99=90=E6=95=B0=E9=87=8F=E4=B8=8Edcaps?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E6=9C=80=E5=A4=A7=E9=99=90=E5=88=B6=20?= =?UTF-8?q?=E6=9D=83=E9=99=90=E7=8A=B6=E6=80=81=E8=A1=A8=E7=9A=84deviceID?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=86=99=E4=B8=BAPHONE-001?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xia-bubai --- interfaces/innerkits/nativetoken/include/nativetoken.h | 1 + interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c | 2 +- .../nativetoken/test/unittest/src/nativetoken_oper_test.cpp | 2 +- .../main/cpp/src/database/data_translator.cpp | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/nativetoken/include/nativetoken.h b/interfaces/innerkits/nativetoken/include/nativetoken.h index 6c403e02e..78ec21af5 100644 --- a/interfaces/innerkits/nativetoken/include/nativetoken.h +++ b/interfaces/innerkits/nativetoken/include/nativetoken.h @@ -42,6 +42,7 @@ extern "C" { #define TOKEN_RANDOM_MASK ((1 << 20) - 1) #define MAX_RETRY_LOCK_TIMES 10 #define SLEEP_TIME (500*1000) +#define MAX_MALLOC_SIZE 8192 #define ATRET_FAILED 1 #define ATRET_SUCCESS 0 diff --git a/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c b/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c index 0288d6adc..3108c96a8 100644 --- a/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c +++ b/interfaces/innerkits/nativetoken/src/nativetoken_json_oper.c @@ -90,7 +90,7 @@ uint32_t GetInfoArrFromJson(cJSON *cjsonItem, char **strArr[], int32_t *strNum, { cJSON *strArrJson = cJSON_GetObjectItem(cjsonItem, attr->strKey); int32_t size = cJSON_GetArraySize(strArrJson); - if (size > attr->maxStrNum) { + if (size > MAX_MALLOC_SIZE) { NativeTokenKmsg(NATIVETOKEN_KERROR, "[%s]:size = %d is invalid.", __func__, size); return ATRET_FAILED; } diff --git a/interfaces/innerkits/nativetoken/test/unittest/src/nativetoken_oper_test.cpp b/interfaces/innerkits/nativetoken/test/unittest/src/nativetoken_oper_test.cpp index abc3a6258..6734205df 100644 --- a/interfaces/innerkits/nativetoken/test/unittest/src/nativetoken_oper_test.cpp +++ b/interfaces/innerkits/nativetoken/test/unittest/src/nativetoken_oper_test.cpp @@ -188,7 +188,7 @@ HWTEST_F(TokenOperTest, GetInfoArrFromJson001, TestSize.Level1) "\"dcaps\":[\"DCAPS_AT\",\"DCAPS_AT\", \"DCAPS_AT\",\"DCAPS_AT\"]," "\"permissions\":[],\"nativeAcls\":[]}"; cJSON* jsonroot = cJSON_Parse(stringJson1); - EXPECT_NE(GetInfoArrFromJson(jsonroot, &test, &resSize, &attr), 0); + EXPECT_EQ(GetInfoArrFromJson(jsonroot, &test, &resSize, &attr), 0); cJSON_Delete(jsonroot); stringJson1 = "{\"processName\":\"partitionslot_host\"," diff --git a/services/accesstokenmanager/main/cpp/src/database/data_translator.cpp b/services/accesstokenmanager/main/cpp/src/database/data_translator.cpp index 582841fd7..fc38a12af 100644 --- a/services/accesstokenmanager/main/cpp/src/database/data_translator.cpp +++ b/services/accesstokenmanager/main/cpp/src/database/data_translator.cpp @@ -76,7 +76,7 @@ int DataTranslator::TranslationIntoGenericValues(const PermissionStatus& inPermi GenericValues& outGenericValues) { outGenericValues.Put(TokenFiledConst::FIELD_PERMISSION_NAME, inPermissionState.permissionName); - outGenericValues.Put(TokenFiledConst::FIELD_DEVICE_ID, ""); + outGenericValues.Put(TokenFiledConst::FIELD_DEVICE_ID, "PHONE-001"); outGenericValues.Put(TokenFiledConst::FIELD_GRANT_STATE, inPermissionState.grantStatus); int32_t grantFlag = static_cast(inPermissionState.grantFlag); outGenericValues.Put(TokenFiledConst::FIELD_GRANT_FLAG, grantFlag); -- Gitee