diff --git a/interfaces/innerkits/nativetoken/include/nativetoken.h b/interfaces/innerkits/nativetoken/include/nativetoken.h index 6c403e02ed59aa611fb6a07d638f32d9d96aec24..78ec21af5d3cae415f55ee1553403a96990d05e6 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 0288d6adca07af233a59f6ae46e9217be6242cdb..3108c96a844779319c5dc4b8fb4eea43a91f749c 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 abc3a6258ca9ac301cf1a29b50e3c017a3007429..6734205dffac4cde1eaf95edfab0815ca4e5686c 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 582841fd7daf9da434f923e6fdf04ebeb83c2738..fc38a12af000a28e5d2550c373ceda9d62871112 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);