From e4d3851227b697317d656686a9446a3f6cdfb2f8 Mon Sep 17 00:00:00 2001 From: yangshx Date: Mon, 29 Jul 2024 19:19:46 +0800 Subject: [PATCH 01/12] add btproxy syscap define Signed-off-by: yangshx --- include/codec_config/syscap_define.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/codec_config/syscap_define.h b/include/codec_config/syscap_define.h index d1675f6..93db749 100644 --- a/include/codec_config/syscap_define.h +++ b/include/codec_config/syscap_define.h @@ -354,6 +354,7 @@ typedef enum SystemCapabilityNum { ABILITY_APPEXTENSION_PHOTOEDITOREXTENSION, HIVIEWDFX_HICOLLIE, BUNDLEMANAGER_APPDOMAINVERIFY, + COMMUNICATION_NETMANAGER_BTPROXY, // Add before here SYSCAP_BASIC_END = 500, } SyscapNum; @@ -691,6 +692,7 @@ const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Customization.CustomConfig", CUSTOMIZATION_CUSTOMCONFIG}, {"SystemCapability.Ability.AppExtension.PhotoEditorExtension", ABILITY_APPEXTENSION_PHOTOEDITOREXTENSION}, {"SystemCapability.BundleManager.AppDomainVerify", BUNDLEMANAGER_APPDOMAINVERIFY}, + {"SystemCapability.Communication.NetManager.Btproxy", COMMUNICATION_NETMANAGER_BTPROXY}, }; #ifdef __cplusplus -- Gitee From 55657220adad87d4e20a304d96aa89658d97fa7b Mon Sep 17 00:00:00 2001 From: xuezhou_yan Date: Sat, 3 Aug 2024 09:28:38 +0800 Subject: [PATCH 02/12] =?UTF-8?q?#IAHKVH=20=E5=91=8A=E8=AD=A6=E6=B8=85?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E7=A1=AE=E4=BF=9D=E6=9C=89=E7=AC=A6=E5=8F=B7?= =?UTF-8?q?=E6=95=B4=E6=95=B0=E8=BF=90=E7=AE=97=E4=B8=8D=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuezhou_yan --- src/create_pcid.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index 4972ac9..0549f05 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -358,7 +358,7 @@ static int32_t GetPriSyscapResult(cJSON *capVectorPtr, int32_t ret) return ret; } -int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufLen) +int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, uint32_t contextBufLen) { cJSON *capVectorPtr = cJSON_CreateArray(); if (capVectorPtr == NULL) { @@ -366,11 +366,6 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL return -1; } - if (contextBufLen > UINT32_MAX) { - PRINT_ERR("the data privateSyscapLen is out of scope."); - return GetPriSyscapResult(capVectorPtr, -1); - } - int32_t privateSyscapLen = (int32_t)(contextBufLen - sizeof(PCIDMain) - 1); if (privateSyscapLen < 0 || privateSyscapLen > INT32_MAX) { PRINT_ERR("parse private syscap failed."); -- Gitee From e4b288b528f4a9922a9a0713725dc6f1662b6706 Mon Sep 17 00:00:00 2001 From: markYao Date: Tue, 6 Aug 2024 12:39:13 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=96=B0=E5=A2=9Esyscap,=20"SystemCapability.Notification.Noti?= =?UTF-8?q?ficationSettings"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: markYao --- include/codec_config/syscap_define.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/codec_config/syscap_define.h b/include/codec_config/syscap_define.h index 93db749..8b0b6c9 100644 --- a/include/codec_config/syscap_define.h +++ b/include/codec_config/syscap_define.h @@ -355,6 +355,7 @@ typedef enum SystemCapabilityNum { HIVIEWDFX_HICOLLIE, BUNDLEMANAGER_APPDOMAINVERIFY, COMMUNICATION_NETMANAGER_BTPROXY, + NOTIFICATION_NOTIFICATIONSETTINGS, // Add before here SYSCAP_BASIC_END = 500, } SyscapNum; @@ -693,6 +694,7 @@ const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Ability.AppExtension.PhotoEditorExtension", ABILITY_APPEXTENSION_PHOTOEDITOREXTENSION}, {"SystemCapability.BundleManager.AppDomainVerify", BUNDLEMANAGER_APPDOMAINVERIFY}, {"SystemCapability.Communication.NetManager.Btproxy", COMMUNICATION_NETMANAGER_BTPROXY}, + {"SystemCapability.Notification.NotificationSettings", NOTIFICATION_NOTIFICATIONSETTINGS}, }; #ifdef __cplusplus -- Gitee From 697cc6e13eb6dd85948039927991d18c62c72919 Mon Sep 17 00:00:00 2001 From: liutuantuan Date: Mon, 5 Aug 2024 22:48:19 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liutuantuan --- BUILD.gn | 3 ++ interfaces/inner_api/syscap_interface.c | 12 ++++++- src/common_method.c | 24 +++++++++++++ src/common_method.h | 23 ++++++++++++ src/context_tool.c | 6 ++-- src/create_pcid.c | 47 ++++++++++++++----------- src/syscap_tool.c | 29 +++++++++++---- test/unittest/common/BUILD.gn | 2 ++ 8 files changed, 116 insertions(+), 30 deletions(-) create mode 100644 src/common_method.c create mode 100644 src/common_method.h diff --git a/BUILD.gn b/BUILD.gn index 870dbae..c7becf1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -29,6 +29,7 @@ sources_platform_common = [ "./src/create_pcid.c", "./src/endian_internal.c", "./src/context_tool.c", + "./src/common_method.c", ] ohos_executable("syscap_tool_bin") { @@ -97,6 +98,7 @@ if (defined(ohos_lite)) { "./src/context_tool.c", "./src/endian_internal.c", "./src/syscap_tool.c", + "./src/common_method.c", ] deps += [ @@ -121,6 +123,7 @@ if (defined(ohos_lite)) { "./src/context_tool.c", "./src/endian_internal.c", "./src/syscap_tool.c", + "./src/common_method.c", ] external_deps = [ "bounds_checking_function:libsec_static", diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 017eb5b..0580c69 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -26,6 +26,7 @@ #include "endian_internal.h" #include "syscap_interface.h" #include "context_tool.h" +#include "common_method.h" #ifdef SYSCAP_DEFINE_EXTERN_ENABLE #include "syscap_define_custom.h" @@ -292,6 +293,10 @@ static int32_t ParseRpcidToJson(char *input, uint32_t inputLen, cJSON *rpcidJson char *sysCapBegin = input + sizeof(RPCIDHead) + sizeof(uint32_t); RPCIDHead *rpcidHeader = (RPCIDHead *)input; cJSON *sysCapJson = cJSON_CreateArray(); + if (sysCapJson == NULL) { + PRINT_ERR("Get sysCapJson failed, sysCapJson is empty.\n"); + ret = -1; + } for (i = 0; i < sysCapCount; i++) { char *temp = sysCapBegin + i * SINGLE_FEAT_LEN; if (strlen(temp) >= SINGLE_FEAT_LEN) { @@ -443,7 +448,7 @@ static char *FreeAfterDecodeRpcidToString(struct FreeAfterDecodeRpcidInfo freeAf { switch (type) { case FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID: - free(freeAfterDecodeRpcidInfo.priSyscap); + SafeFree(freeAfterDecodeRpcidInfo.priSyscap); free(freeAfterDecodeRpcidInfo.osSysCapIndex); cJSON_Delete(freeAfterDecodeRpcidInfo.sysCapDefine); cJSON_Delete(freeAfterDecodeRpcidInfo.rpcidRoot); @@ -495,6 +500,11 @@ char *DecodeRpcidToStringFormat(const char *inputFile) // parse rpcid to json freeAfterDecodeRpcidInfo.rpcidRoot = cJSON_CreateObject(); + if (freeAfterDecodeRpcidInfo.rpcidRoot == NULL) { + PRINT_ERR("Failed to create cJSON object for rpcidRoot\n"); + return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_CONTEXT_OUT_AFTER_DECODE_RPCID, outBuffer); + } + if (ParseRpcidToJson(freeAfterDecodeRpcidInfo.contextBuffer, bufferLen, freeAfterDecodeRpcidInfo.rpcidRoot)) { PRINT_ERR("Prase rpcid to json failed. Input file: %s\n", inputFile); return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_RPCID_ROOT_AFTER_DECODE_RPCID, outBuffer); diff --git a/src/common_method.c b/src/common_method.c new file mode 100644 index 0000000..cf7880f --- /dev/null +++ b/src/common_method.c @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "common_method.h" +#include + +void SafeFree(char *pointer) +{ + if ((pointer) != NULL) { + free(pointer); + } +} diff --git a/src/common_method.h b/src/common_method.h new file mode 100644 index 0000000..a9030bb --- /dev/null +++ b/src/common_method.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMON_METHOD_H +#define COMMON_METHOD_H + +#include + +void SafeFree(char *pointer); + +#endif \ No newline at end of file diff --git a/src/context_tool.c b/src/context_tool.c index 1440a6b..ea5359f 100644 --- a/src/context_tool.c +++ b/src/context_tool.c @@ -155,23 +155,25 @@ int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *len) } if (bufferLen < (2 * sizeof(uint32_t))) { // 2, header of rpcid.sc PRINT_ERR("Parse file failed(format is invalid), input file : %s\n", inputFile); - free(contextBuffer); + FreeContextBuffer(contextBuffer); return -1; } rpcidHeader = (RPCIDHead *)contextBuffer; if (rpcidHeader->apiVersionType != 1) { PRINT_ERR("Parse file failed(apiVersionType != 1), input file : %s\n", inputFile); - free(contextBuffer); + FreeContextBuffer(contextBuffer); return -1; } sysCaptype = NtohsInter(*(uint16_t *)(rpcidHeader + 1)); if (sysCaptype != 2) { // 2, app syscap type PRINT_ERR("Parse file failed(sysCaptype != 2), input file : %s\n", inputFile); + FreeContextBuffer(contextBuffer); return -1; } sysCapLength = NtohsInter(*(uint16_t *)((char *)(rpcidHeader + 1) + sizeof(uint16_t))); if (bufferLen < sizeof(RPCIDHead) + sizeof(uint32_t) + sysCapLength) { PRINT_ERR("Parse file failed(SysCap length exceeded), input file : %s\n", inputFile); + FreeContextBuffer(contextBuffer); return -1; } diff --git a/src/create_pcid.c b/src/create_pcid.c index 4972ac9..5a73c71 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -25,6 +25,7 @@ #include "endian_internal.h" #include "create_pcid.h" #include "context_tool.h" +#include "common_method.h" #ifdef SYSCAP_DEFINE_EXTERN_ENABLE #include "syscap_define_custom.h" @@ -58,7 +59,6 @@ struct FreeEncodePcidInfo { char *outDirPathFinal; }; - struct FreeDecodePcidJsonInfo { char *strJson; char *contextBuffer; @@ -271,6 +271,7 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) cJSON *jsonOsSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "os"); cJSON *jsonPriSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "private"); + ret = GetOsAndPriSyscapSize(jsonOsSyscapObj, jsonPriSyscapObj, &osCapSize, &privateCapSize); if (ret != 0) { return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); @@ -526,15 +527,18 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_ROOT_OUT, ret); } - freePcidJsonInfo.sysCapObj = NULL; // avoid being released repeatedly. + freePcidJsonInfo.strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); + if (freePcidJsonInfo.strJson == NULL) { + PRINT_ERR("cJSON_Print failed to generate JSON string\n"); + return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_ROOT_OUT, -1); + } - char *strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); const char outputFileName[] = "pcid.json"; - ret = ConvertedContextSaveAsFile(outDirPath, outputFileName, strJson, strlen(strJson)); + ret = ConvertedContextSaveAsFile(outDirPath, outputFileName, freePcidJsonInfo.strJson, + strlen(freePcidJsonInfo.strJson)); if (ret != 0) { PRINT_ERR("ConvertedContextSaveAsFile failed, outDirPath:%s, filename:%s\n", outDirPath, outputFileName); } - free(strJson); return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONVERT_OUT, ret); } @@ -665,7 +669,6 @@ static int32_t AddPriSyscapToJsonObj(char *priSyscapString, uint32_t priSyscapSt cJSON *sysCapArray = cJSON_CreateArray(); if (sysCapArray == NULL) { PRINT_ERR("Create cJSON array failed.\n"); - free(sysCapArray); return -1; } if (priSyscapStringLen == 0) { @@ -701,7 +704,6 @@ static int32_t GetSyscapStr(char *input, char const *priSyscapStr, uint32_t* osS uint32_t fileContextLen; if (GetFileContext(input, &ctx, (uint32_t *)&fileContextLen) != 0) { PRINT_ERR("GetFileContext failed, input file : %s\n", input); - free(ctx); return -1; } if (ParseStringSyscap(ctx, osSyscap, OS_SYSCAP_NUM, pcidHeader, PCID_HEADER) != 0) { @@ -719,6 +721,7 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath) uint32_t osSyscap[OS_SYSCAP_NUM] = {0}; uint32_t pcidHeader[PCID_HEADER]; char *priSyscapStr = NULL; + char *jsonBuffer = NULL; ret = GetSyscapStr(input, priSyscapStr, osSyscap, pcidHeader); if (ret == -1) { return ret; @@ -727,40 +730,44 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath) // add to json object cJSON *sysCapObj = cJSON_CreateObject(); cJSON *rootObj = cJSON_CreateObject(); + if (sysCapObj == NULL || rootObj == NULL) { + PRINT_ERR("Failed to create cJSON objects.\n"); + goto FAILED; + } + if (!cJSON_AddItemToObject(rootObj, "syscap", sysCapObj)) { PRINT_ERR("Add syscap to json failed.\n"); - goto ADD_JSON_FAILED; + goto FAILED; } if (AddHeaderToJsonObj(pcidHeader, PCID_HEADER, rootObj) != 0) { PRINT_ERR("Add header to json object failed.\n"); - goto ADD_JSON_FAILED; + goto FAILED; } if (AddOsSyscapToJsonObj(osSyscap, OS_SYSCAP_NUM, sysCapObj) != 0) { PRINT_ERR("Add os syscap json object failed.\n"); - goto ADD_JSON_FAILED; + goto FAILED; } - if (AddPriSyscapToJsonObj(priSyscapStr, (uint32_t)strlen(priSyscapStr), sysCapObj) != 0) { + if (AddPriSyscapToJsonObj(priSyscapStr, (uint32_t) strlen(priSyscapStr), sysCapObj) != 0) { PRINT_ERR("Add private syscap json object failed.\n"); - goto ADD_JSON_FAILED; + goto FAILED; } // save as json file - char *jsonBuffer = cJSON_Print(rootObj); + jsonBuffer = cJSON_Print(rootObj); if (jsonBuffer == NULL) { PRINT_ERR("json buffer is null.\n"); - goto ADD_JSON_FAILED; + goto FAILED; } const char outputFileName[] = "pcid.json"; - if (ConvertedContextSaveAsFile(outDirPath, outputFileName, - jsonBuffer, strlen(jsonBuffer)) != 0) { + if (ConvertedContextSaveAsFile(outDirPath, outputFileName, jsonBuffer, strlen(jsonBuffer)) != 0) { PRINT_ERR("Save as json file failed.\n"); - goto SAVE_FAILED; + goto FAILED; } ret = 0; -SAVE_FAILED: - free(jsonBuffer); -ADD_JSON_FAILED: +FAILED: + SafeFree(jsonBuffer); + SafeFree(priSyscapStr); cJSON_Delete(sysCapObj); cJSON_Delete(rootObj); return ret; diff --git a/src/syscap_tool.c b/src/syscap_tool.c index b2ab4fd..93d3344 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -27,6 +27,7 @@ #include "create_pcid.h" #include "syscap_tool.h" #include "context_tool.h" +#include "common_method.h" #ifdef SYSCAP_DEFINE_EXTERN_ENABLE #include "syscap_define_custom.h" @@ -71,6 +72,14 @@ struct FreeAfterEncodeRpcidscInfo { int16_t flag; }; +static void FreePointerMemory(char *pcidContent, char *rpcidContent, char *pcidPriSyscap, char *rpcidPriSyscap) +{ + SafeFree(pcidContent); + SafeFree(rpcidPriSyscap); + SafeFree(rpcidContent); + SafeFree(pcidPriSyscap); +} + static int32_t FillOsCapLength(char *convertedBuffer, char *contextBuffer, struct JsonObjectSysCap gJsonObjectSysCap, uint32_t sysCapSize, int32_t ret) { @@ -204,6 +213,11 @@ static int32_t ParseRpcidToJson(char *input, uint32_t inputLen, cJSON *rpcidJson char *sysCapBegin = input + sizeof(RPCIDHead) + sizeof(uint32_t); RPCIDHead *rpcidHeader = (RPCIDHead *)input; cJSON *sysCapJson = cJSON_CreateArray(); + if (sysCapJson == NULL) { + PRINT_ERR("Failed to create sysCapJson array\n"); + return -1; + } + for (i = 0; i < sysCapCount; i++) { char *temp = sysCapBegin + i * SINGLE_FEAT_LEN; if (strlen(temp) >= SINGLE_FEAT_LEN || strlen(temp) == 0) { @@ -263,13 +277,16 @@ int32_t RPCIDDecode(char *inputFile, char *outputPath) // save to json file convertedBuffer = cJSON_Print(rpcidRoot); + if (convertedBuffer == NULL) { + PRINT_ERR("cJSON_Print failed to create JSON string\n"); + goto FREE_RPCID_ROOT; + } + ret = ConvertedContextSaveAsFile(outputPath, "rpcid.json", convertedBuffer, strlen(convertedBuffer)); if (ret != 0) { PRINT_ERR("ConvertedContextSaveAsFile failed, outputPath:%s, filename:rpcid.json\n", outputPath); - free(convertedBuffer); goto FREE_RPCID_ROOT; } - free(convertedBuffer); FREE_RPCID_ROOT: cJSON_Delete(rpcidRoot); @@ -705,10 +722,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ &rpcidPriSyscap, &rpcidPriSyscapLen); if (ret != 0) { PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret); - free(pcidContent); - free(rpcidContent); - free(pcidPriSyscap); - free(rpcidPriSyscap); + FreePointerMemory(pcidContent, rpcidContent, pcidPriSyscap, rpcidPriSyscap); return -1; } @@ -720,5 +734,6 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ } else { printf("Fail! The pcid does not meet the rpcid\n"); } + return 0; -} \ No newline at end of file +} diff --git a/test/unittest/common/BUILD.gn b/test/unittest/common/BUILD.gn index 668ac7d..2621342 100644 --- a/test/unittest/common/BUILD.gn +++ b/test/unittest/common/BUILD.gn @@ -41,6 +41,7 @@ if (defined(ohos_lite)) { "../../../src/create_pcid.c", "../../../src/endian_internal.c", "../../../src/syscap_tool.c", + "../../../src/common_method.c", "syscap_codec_test.cpp", ] @@ -82,6 +83,7 @@ if (defined(ohos_lite)) { "../../../src/create_pcid.c", "../../../src/endian_internal.c", "../../../src/syscap_tool.c", + "../../../src/common_method.c", "syscap_codec_test.cpp", ] -- Gitee From 33298c4c7442bc6504076ea1f4eae1c0f5f38963 Mon Sep 17 00:00:00 2001 From: liutuantuan Date: Wed, 7 Aug 2024 10:53:58 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liutuantuan --- src/create_pcid.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index 5a73c71..c2aa7e7 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -528,10 +528,6 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) } freePcidJsonInfo.strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); - if (freePcidJsonInfo.strJson == NULL) { - PRINT_ERR("cJSON_Print failed to generate JSON string\n"); - return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_ROOT_OUT, -1); - } const char outputFileName[] = "pcid.json"; ret = ConvertedContextSaveAsFile(outDirPath, outputFileName, freePcidJsonInfo.strJson, -- Gitee From 34c4748e63b7f6f56cd97576c0cd7946c57246ef Mon Sep 17 00:00:00 2001 From: huchunlan1 Date: Thu, 8 Aug 2024 10:08:31 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E8=93=9D=E7=89=99=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E9=80=82=E9=85=8D=E5=BC=80=E5=8F=91=E8=80=85?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=90=8D=E7=A7=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huchunlan1 --- include/codec_config/syscap_define.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/codec_config/syscap_define.h b/include/codec_config/syscap_define.h index 8b0b6c9..1b6db54 100644 --- a/include/codec_config/syscap_define.h +++ b/include/codec_config/syscap_define.h @@ -354,7 +354,7 @@ typedef enum SystemCapabilityNum { ABILITY_APPEXTENSION_PHOTOEDITOREXTENSION, HIVIEWDFX_HICOLLIE, BUNDLEMANAGER_APPDOMAINVERIFY, - COMMUNICATION_NETMANAGER_BTPROXY, + COMMUNICATION_NETMANAGER_BLUETOOTH, NOTIFICATION_NOTIFICATIONSETTINGS, // Add before here SYSCAP_BASIC_END = 500, @@ -693,7 +693,7 @@ const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Customization.CustomConfig", CUSTOMIZATION_CUSTOMCONFIG}, {"SystemCapability.Ability.AppExtension.PhotoEditorExtension", ABILITY_APPEXTENSION_PHOTOEDITOREXTENSION}, {"SystemCapability.BundleManager.AppDomainVerify", BUNDLEMANAGER_APPDOMAINVERIFY}, - {"SystemCapability.Communication.NetManager.Btproxy", COMMUNICATION_NETMANAGER_BTPROXY}, + {"SystemCapability.Communication.NetManager.Bluetooth", COMMUNICATION_NETMANAGER_BLUETOOTH}, {"SystemCapability.Notification.NotificationSettings", NOTIFICATION_NOTIFICATIONSETTINGS}, }; -- Gitee From 91d373c62c91b9b256ef603dfec8c33ce41b457d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E5=AD=A6=E8=88=9F?= Date: Thu, 8 Aug 2024 02:51:21 +0000 Subject: [PATCH 07/12] update src/create_pcid.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 严学舟 --- src/create_pcid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index 0549f05..c346a43 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -358,7 +358,7 @@ static int32_t GetPriSyscapResult(cJSON *capVectorPtr, int32_t ret) return ret; } -int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, uint32_t contextBufLen) +int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, int32_t contextBufLen) { cJSON *capVectorPtr = cJSON_CreateArray(); if (capVectorPtr == NULL) { @@ -366,7 +366,7 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, uint32_t contextBu return -1; } - int32_t privateSyscapLen = (int32_t)(contextBufLen - sizeof(PCIDMain) - 1); + int32_t privateSyscapLen = contextBufLen - sizeof(PCIDMain) - 1; if (privateSyscapLen < 0 || privateSyscapLen > INT32_MAX) { PRINT_ERR("parse private syscap failed."); return GetPriSyscapResult(capVectorPtr, -1); -- Gitee From 4972a2abb56b028b59bfc1118f2d1925fed8aa87 Mon Sep 17 00:00:00 2001 From: xuedong Date: Thu, 8 Aug 2024 15:54:49 +0800 Subject: [PATCH 08/12] add VideoProcessingEngine capability Signed-off-by: xuedong --- include/codec_config/syscap_define.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/codec_config/syscap_define.h b/include/codec_config/syscap_define.h index 8b0b6c9..6730e72 100644 --- a/include/codec_config/syscap_define.h +++ b/include/codec_config/syscap_define.h @@ -356,6 +356,7 @@ typedef enum SystemCapabilityNum { BUNDLEMANAGER_APPDOMAINVERIFY, COMMUNICATION_NETMANAGER_BTPROXY, NOTIFICATION_NOTIFICATIONSETTINGS, + MULTIMEDIA_VIDEOPROCESSINGENGINE, // Add before here SYSCAP_BASIC_END = 500, } SyscapNum; @@ -695,6 +696,7 @@ const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.BundleManager.AppDomainVerify", BUNDLEMANAGER_APPDOMAINVERIFY}, {"SystemCapability.Communication.NetManager.Btproxy", COMMUNICATION_NETMANAGER_BTPROXY}, {"SystemCapability.Notification.NotificationSettings", NOTIFICATION_NOTIFICATIONSETTINGS}, + {"SystemCapability.Multimedia.VideoProcessingEngine", MULTIMEDIA_VIDEOPROCESSINGENGINE}, }; #ifdef __cplusplus -- Gitee From 5154aa66ae98171109ff3487683e2503b47ac1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E5=AD=A6=E8=88=9F?= Date: Thu, 8 Aug 2024 07:56:09 +0000 Subject: [PATCH 09/12] update src/create_pcid.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 严学舟 --- src/create_pcid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index c346a43..ad3755c 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -358,7 +358,7 @@ static int32_t GetPriSyscapResult(cJSON *capVectorPtr, int32_t ret) return ret; } -int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, int32_t contextBufLen) +static int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, int32_t contextBufLen) { cJSON *capVectorPtr = cJSON_CreateArray(); if (capVectorPtr == NULL) { -- Gitee From 439ca5930226205bf43d70957c8ef066e0160e0b Mon Sep 17 00:00:00 2001 From: xuezhou_yan Date: Fri, 9 Aug 2024 17:26:47 +0800 Subject: [PATCH 10/12] =?UTF-8?q?issue:#IAJ1T8=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E7=94=A8=E4=BE=8Bdoublefree=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuezhou_yan --- src/create_pcid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/create_pcid.c b/src/create_pcid.c index 9a249e3..36f0f20 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -522,6 +522,8 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_ROOT_OUT, ret); } + freePcidJsonInfo.sysCapObj = NULL; // avoid being released repeatedly. + freePcidJsonInfo.strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); const char outputFileName[] = "pcid.json"; -- Gitee From 323c4df5e17234efe50a0c5e262a5d01b6e3c1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E5=AD=A6=E8=88=9F?= Date: Sat, 10 Aug 2024 02:17:18 +0000 Subject: [PATCH 11/12] update src/create_pcid.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 严学舟 --- src/create_pcid.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index 36f0f20..3c0db87 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -450,7 +450,6 @@ static int32_t FreeAfterDecodePCID(struct FreeDecodePcidJsonInfo freePcidJsonInf case FREE_DECODE_PCID_CONVERT_OUT: free(freePcidJsonInfo.strJson); cJSON_Delete(freePcidJsonInfo.jsonRootObj); - cJSON_Delete(freePcidJsonInfo.sysCapObj); FreeContextBuffer(freePcidJsonInfo.contextBuffer); break; case FREE_DECODE_PCID_ROOT_OUT: @@ -463,6 +462,7 @@ static int32_t FreeAfterDecodePCID(struct FreeDecodePcidJsonInfo freePcidJsonInf FreeContextBuffer(freePcidJsonInfo.contextBuffer); break; case FREE_DECODE_PCID_CONTEXT_OUT: + cJSON_Delete(freePcidJsonInfo.sysCapObj); default: FreeContextBuffer(freePcidJsonInfo.contextBuffer); } @@ -522,8 +522,6 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_ROOT_OUT, ret); } - freePcidJsonInfo.sysCapObj = NULL; // avoid being released repeatedly. - freePcidJsonInfo.strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); const char outputFileName[] = "pcid.json"; -- Gitee From 4a20b4bd032f920246649a082cf2bdf019d9112d Mon Sep 17 00:00:00 2001 From: lanming Date: Wed, 14 Aug 2024 16:38:58 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E5=8A=A0=E8=A7=A3=E5=AF=86=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E5=BA=93=E6=A1=86=E6=9E=B6=E6=96=B0=E5=A2=9Esyscap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lanming --- include/codec_config/syscap_define.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/codec_config/syscap_define.h b/include/codec_config/syscap_define.h index adab79a..ce2e07d 100644 --- a/include/codec_config/syscap_define.h +++ b/include/codec_config/syscap_define.h @@ -357,6 +357,16 @@ typedef enum SystemCapabilityNum { COMMUNICATION_NETMANAGER_BLUETOOTH, NOTIFICATION_NOTIFICATIONSETTINGS, MULTIMEDIA_VIDEOPROCESSINGENGINE, + SECURITY_CRYPTOFRAMEWORK_KEY, + SECURITY_CRYPTOFRAMEWORK_KEY_SYMKEY, + SECURITY_CRYPTOFRAMEWORK_KEY_ASYMKEY, + SECURITY_CRYPTOFRAMEWORK_SIGNATURE, + SECURITY_CRYPTOFRAMEWORK_CIPHER, + SECURITY_CRYPTOFRAMEWORK_KEYAGREEMENT, + SECURITY_CRYPTOFRAMEWORK_MESSAGEDIGEST, + SECURITY_CRYPTOFRAMEWORK_MAC, + SECURITY_CRYPTOFRAMEWORK_KDF, + SECURITY_CRYPTOFRAMEWORK_RAND, // Add before here SYSCAP_BASIC_END = 500, } SyscapNum; @@ -697,6 +707,16 @@ const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Communication.NetManager.Bluetooth", COMMUNICATION_NETMANAGER_BLUETOOTH}, {"SystemCapability.Notification.NotificationSettings", NOTIFICATION_NOTIFICATIONSETTINGS}, {"SystemCapability.Multimedia.VideoProcessingEngine", MULTIMEDIA_VIDEOPROCESSINGENGINE}, + {"SystemCapability.Security.CryptoFramework.Key", SECURITY_CRYPTOFRAMEWORK_KEY}, + {"SystemCapability.Security.CryptoFramework.Key.SymKey", SECURITY_CRYPTOFRAMEWORK_KEY_SYMKEY}, + {"SystemCapability.Security.CryptoFramework.Key.AsymKey", SECURITY_CRYPTOFRAMEWORK_KEY_ASYMKEY}, + {"SystemCapability.Security.CryptoFramework.Signature", SECURITY_CRYPTOFRAMEWORK_SIGNATURE}, + {"SystemCapability.Security.CryptoFramework.Cipher", SECURITY_CRYPTOFRAMEWORK_CIPHER}, + {"SystemCapability.Security.CryptoFramework.KeyAgreement", SECURITY_CRYPTOFRAMEWORK_KEYAGREEMENT}, + {"SystemCapability.Security.CryptoFramework.MessageDigest", SECURITY_CRYPTOFRAMEWORK_MESSAGEDIGEST}, + {"SystemCapability.Security.CryptoFramework.Mac", SECURITY_CRYPTOFRAMEWORK_MAC}, + {"SystemCapability.Security.CryptoFramework.Kdf", SECURITY_CRYPTOFRAMEWORK_KDF}, + {"SystemCapability.Security.CryptoFramework.Rand", SECURITY_CRYPTOFRAMEWORK_RAND}, }; #ifdef __cplusplus -- Gitee