From 8fd8e84bea6edb88707f92c5376b44f05c9d1746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=B9=8F=E6=98=8A?= Date: Wed, 31 Jul 2024 12:11:15 +0000 Subject: [PATCH 1/8] fix: Modify format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨鹏昊 --- interfaces/inner_api/syscap_interface.c | 10 ++++++ napi/napi_query_syscap.cpp | 5 +++ src/syscap_tool.c | 47 ++++++++++++++++++++----- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 017eb5b..2dcb580 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -292,6 +292,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("Get SysCap 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) { @@ -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; + } + 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/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index f089b36..e8264cb 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -140,6 +140,11 @@ static char* GetSystemCapability() } } retBool = DecodePrivateSyscap(priOutput, &priCapArray, &priCapArrayCnt); + if (priOutput == nullptr) { + PRINT_ERR("priOutput is unexpectedly NULL after DecodePrivateSyscap."); + goto FREE_PRIOUTPUT; + } + allSyscapBuffer = CalculateAllStringLength(osCapArray, priCapArray, retBool, priCapArrayCnt); free(priCapArray); diff --git a/src/syscap_tool.c b/src/syscap_tool.c index b2ab4fd..b40cc90 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -670,6 +670,36 @@ static int32_t CompareVersion(uint32_t *pcidOsArray, uint32_t *rpcidOsAarry) return versionFlag; } +int32_t separate_syscap_from_string(int32_t ret, char *pcidContent, + char *rpcidContent, char *pcidPriSyscap, char *rpcidPriSyscap) { + if (ret != 0) { + PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret); + return; + } + + if (pcidContent == NULL) { + free(pcidContent); + return; + } + + if (rpcidPriSyscap == NULL) { + free(rpcidPriSyscap); + return; + } + + if (rpcidContent == NULL) { + free(rpcidContent); + return; + } + + if (pcidPriSyscap == NULL) { + free(pcidPriSyscap); + return; + } + return -1; +} + + int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t type) { int32_t ret; @@ -703,14 +733,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ &pcidPriSyscap, &pcidPriSyscapLen); ret += SeparateSyscapFromString(rpcidContent, rpcidOsAarry, RPCID_OUT_BUFFER, &rpcidPriSyscap, &rpcidPriSyscapLen); - if (ret != 0) { - PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret); - free(pcidContent); - free(rpcidContent); - free(pcidPriSyscap); - free(rpcidPriSyscap); - return -1; - } + ret = separate_syscap_from_string(ret, pcidContent, rpcidContent, pcidPriSyscap, rpcidPriSyscap); int32_t versionFlag = CompareVersion(pcidOsArray, rpcidOsAarry); int32_t ossyscapFlag = CompareOsSyscap(pcidOsArray, rpcidOsAarry); @@ -720,5 +743,13 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ } else { printf("Fail! The pcid does not meet the rpcid\n"); } + + if (type != TYPE_STRING) { + PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret); + free(pcidContent); + free(rpcidContent); + } + free(pcidPriSyscap); + free(rpcidPriSyscap); return 0; } \ No newline at end of file -- Gitee From 8ecec77352fd3817d82e36ddf40158f8c0eca0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=B9=8F=E6=98=8A?= Date: Thu, 1 Aug 2024 05:36:26 +0000 Subject: [PATCH 2/8] fix: Modify format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨鹏昊 --- interfaces/inner_api/syscap_interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 2dcb580..2b5a0b9 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -502,7 +502,8 @@ char *DecodeRpcidToStringFormat(const char *inputFile) freeAfterDecodeRpcidInfo.rpcidRoot = cJSON_CreateObject(); if (freeAfterDecodeRpcidInfo.rpcidRoot == NULL) { PRINT_ERR("Failed to create cJSON object for rpcidRoot\n"); - return; + return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_RPCID_ROOT_AFTER_DECODE_RPCID, + outBuffer);; } if (ParseRpcidToJson(freeAfterDecodeRpcidInfo.contextBuffer, bufferLen, freeAfterDecodeRpcidInfo.rpcidRoot)) { -- Gitee From 9d9f1ec360ef9769468c59fd8a95dd1a84535da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=B9=8F=E6=98=8A?= Date: Thu, 1 Aug 2024 08:05:32 +0000 Subject: [PATCH 3/8] fix: Modify format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨鹏昊 --- interfaces/inner_api/syscap_interface.c | 4 ++-- src/syscap_tool.c | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 2b5a0b9..cc3d819 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -293,8 +293,8 @@ static int32_t ParseRpcidToJson(char *input, uint32_t inputLen, cJSON *rpcidJson RPCIDHead *rpcidHeader = (RPCIDHead *)input; cJSON *sysCapJson = cJSON_CreateArray(); if (sysCapJson == NULL) { - PRINT_ERR("Get SysCap failed, sysCapJson is empty.\n"); - ret = -1; + PRINT_ERR("Get SysCap failed, sysCapJson is empty.\n"); + ret = -1; } for (i = 0; i < sysCapCount; i++) { diff --git a/src/syscap_tool.c b/src/syscap_tool.c index b40cc90..8ff1d3b 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -670,31 +670,26 @@ static int32_t CompareVersion(uint32_t *pcidOsArray, uint32_t *rpcidOsAarry) return versionFlag; } -int32_t separate_syscap_from_string(int32_t ret, char *pcidContent, +int32_t ReleaseRpcidPriSyscappcidAndPriSyscapMemory(int32_t ret, char *pcidContent, char *rpcidContent, char *pcidPriSyscap, char *rpcidPriSyscap) { if (ret != 0) { PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret); - return; } if (pcidContent == NULL) { free(pcidContent); - return; } if (rpcidPriSyscap == NULL) { free(rpcidPriSyscap); - return; } if (rpcidContent == NULL) { free(rpcidContent); - return; } if (pcidPriSyscap == NULL) { free(pcidPriSyscap); - return; } return -1; } @@ -733,7 +728,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ &pcidPriSyscap, &pcidPriSyscapLen); ret += SeparateSyscapFromString(rpcidContent, rpcidOsAarry, RPCID_OUT_BUFFER, &rpcidPriSyscap, &rpcidPriSyscapLen); - ret = separate_syscap_from_string(ret, pcidContent, rpcidContent, pcidPriSyscap, rpcidPriSyscap); + ret = ReleaseRpcidPriSyscappcidAndPriSyscapMemory(ret, pcidContent, rpcidContent, pcidPriSyscap, rpcidPriSyscap); int32_t versionFlag = CompareVersion(pcidOsArray, rpcidOsAarry); int32_t ossyscapFlag = CompareOsSyscap(pcidOsArray, rpcidOsAarry); @@ -745,7 +740,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ } if (type != TYPE_STRING) { - PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret); + PRINT_ERR("Release rpcidContent and pcidContent memory. ret = %d\n", ret); free(pcidContent); free(rpcidContent); } -- Gitee From 39c88aa666d2942805e245752fe2dba321fc081e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=B9=8F=E6=98=8A?= Date: Thu, 1 Aug 2024 08:43:52 +0000 Subject: [PATCH 4/8] fix: Modify format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨鹏昊 --- interfaces/inner_api/syscap_interface.c | 4 +-- src/syscap_tool.c | 37 +++++++++++++------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index cc3d819..5582e25 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -500,10 +500,10 @@ char *DecodeRpcidToStringFormat(const char *inputFile) // parse rpcid to json freeAfterDecodeRpcidInfo.rpcidRoot = cJSON_CreateObject(); - if (freeAfterDecodeRpcidInfo.rpcidRoot == NULL) { + if (freeAfterDecodeRpcidInfo.rpcidRoot == NULL) { PRINT_ERR("Failed to create cJSON object for rpcidRoot\n"); return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_RPCID_ROOT_AFTER_DECODE_RPCID, - outBuffer);; + outBuffer); } if (ParseRpcidToJson(freeAfterDecodeRpcidInfo.contextBuffer, bufferLen, freeAfterDecodeRpcidInfo.rpcidRoot)) { diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 8ff1d3b..db755e4 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -670,28 +670,29 @@ static int32_t CompareVersion(uint32_t *pcidOsArray, uint32_t *rpcidOsAarry) return versionFlag; } -int32_t ReleaseRpcidPriSyscappcidAndPriSyscapMemory(int32_t ret, char *pcidContent, - char *rpcidContent, char *pcidPriSyscap, char *rpcidPriSyscap) { - if (ret != 0) { - PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret); - } +static int32_t ReleaseRpcidPriSyscappcidAndPriSyscapMemory(int32_t ret, char *pcidContent, + char *rpcidContent, char *pcidPriSyscap, char *rpcidPriSyscap) +{ + if (ret != 0) { + PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret); + } - if (pcidContent == NULL) { - free(pcidContent); - } + if (pcidContent == NULL) { + free(pcidContent); + } - if (rpcidPriSyscap == NULL) { - free(rpcidPriSyscap); - } + if (rpcidPriSyscap == NULL) { + free(rpcidPriSyscap); + } - if (rpcidContent == NULL) { - free(rpcidContent); - } + if (rpcidContent == NULL) { + free(rpcidContent); + } - if (pcidPriSyscap == NULL) { - free(pcidPriSyscap); - } - return -1; + if (pcidPriSyscap == NULL) { + free(pcidPriSyscap); + } + return -1; } -- Gitee From 716db041e04445f5c22b2c19e70b7b152b903d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=B9=8F=E6=98=8A?= Date: Fri, 2 Aug 2024 07:02:28 +0000 Subject: [PATCH 5/8] fix: Modify format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨鹏昊 --- src/context_tool.c | 2 ++ src/create_pcid.c | 31 +++++++++++++++++++++++++++++-- src/syscap_tool.c | 10 ++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/context_tool.c b/src/context_tool.c index 1440a6b..dd730a9 100644 --- a/src/context_tool.c +++ b/src/context_tool.c @@ -167,11 +167,13 @@ int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *len) 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); + free(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); + free(contextBuffer); return -1; } diff --git a/src/create_pcid.c b/src/create_pcid.c index 64814f3..b4c34f2 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -265,7 +265,17 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) } cJSON *jsonOsSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "os"); + if (jsonOsSyscapObj == NULL || !cJSON_IsObject(jsonOsSyscapObj)) { + PRINT_ERR("get \"os\" object failed\n"); + return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); + } + cJSON *jsonPriSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "private"); + if (jsonPriSyscapObj == NULL || !cJSON_IsObject(jsonPriSyscapObj)) { + PRINT_ERR("get \"private\" object failed\n"); + return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); + } + ret = GetOsAndPriSyscapSize(jsonOsSyscapObj, jsonPriSyscapObj, &osCapSize, &privateCapSize); if (ret != 0) { return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); @@ -524,6 +534,11 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) freePcidJsonInfo.sysCapObj = NULL; // avoid being released repeatedly. char *strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); + if (strJson == NULL) { + PRINT_ERR("cJSON_Print failed to generate JSON string\n"); + return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONVERT_OUT, -1); + } + const char outputFileName[] = "pcid.json"; ret = ConvertedContextSaveAsFile(outDirPath, outputFileName, strJson, strlen(strJson)); if (ret != 0) { @@ -660,7 +675,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) { @@ -696,7 +710,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) { @@ -721,7 +734,17 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath) // add to json object cJSON *sysCapObj = cJSON_CreateObject(); + if (sysCapObj == NULL) { + free(priSyscapStr); + return -1; + } + cJSON *rootObj = cJSON_CreateObject(); + if (rootObj == NULL) { + free(priSyscapStr); + return -1; + } + if (!cJSON_AddItemToObject(rootObj, "syscap", sysCapObj)) { PRINT_ERR("Add syscap to json failed.\n"); goto ADD_JSON_FAILED; @@ -756,6 +779,10 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath) SAVE_FAILED: free(jsonBuffer); ADD_JSON_FAILED: + if (priSyscapStr != NULL) { + free(priSyscapStr); + } + cJSON_Delete(sysCapObj); cJSON_Delete(rootObj); return ret; diff --git a/src/syscap_tool.c b/src/syscap_tool.c index db755e4..9b97b79 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -204,6 +204,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,6 +268,11 @@ 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); -- Gitee From a29c4f3eecdeb47826b4a39d710ce90a82d79a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=B9=8F=E6=98=8A?= Date: Fri, 2 Aug 2024 09:05:18 +0000 Subject: [PATCH 6/8] fix: Modify format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨鹏昊 --- src/create_pcid.c | 31 ++++++++++++++----------------- src/syscap_tool.c | 1 - 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index b4c34f2..85577be 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -67,6 +67,13 @@ struct FreeDecodePcidJsonInfo { int32_t flag; }; +void safeFree(void *ptr) { + if (ptr != NULL) { + free(ptr); + ptr = NULL; + } +} + int32_t SetOsSyscap(PCIDMain *pcidBuffer, uint32_t osCapSize, const cJSON *jsonOsSyscapObj, const cJSON *allOsSyscapObj) { @@ -535,8 +542,8 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) char *strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); if (strJson == NULL) { - PRINT_ERR("cJSON_Print failed to generate JSON string\n"); - return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONVERT_OUT, -1); + PRINT_ERR("cJSON_Print failed to generate JSON string\n"); + return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONVERT_OUT, -1); } const char outputFileName[] = "pcid.json"; @@ -744,22 +751,12 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath) free(priSyscapStr); return -1; } - - if (!cJSON_AddItemToObject(rootObj, "syscap", sysCapObj)) { - PRINT_ERR("Add syscap to json failed.\n"); - goto ADD_JSON_FAILED; - } - if (AddHeaderToJsonObj(pcidHeader, PCID_HEADER, rootObj) != 0) { - PRINT_ERR("Add header to json object failed.\n"); - goto ADD_JSON_FAILED; - } - if (AddOsSyscapToJsonObj(osSyscap, OS_SYSCAP_NUM, sysCapObj) != 0) { - PRINT_ERR("Add os syscap json object failed.\n"); - goto ADD_JSON_FAILED; - } - if (AddPriSyscapToJsonObj(priSyscapStr, (uint32_t)strlen(priSyscapStr), sysCapObj) != 0) { - PRINT_ERR("Add private syscap json object failed.\n"); + if (!cJSON_AddItemToObject(rootObj, "syscap", sysCapObj) || + AddHeaderToJsonObj(pcidHeader, PCID_HEADER, rootObj) != 0 || + AddOsSyscapToJsonObj(osSyscap, OS_SYSCAP_NUM, sysCapObj) != 0 || + AddPriSyscapToJsonObj(priSyscapStr, (uint32_t)strlen(priSyscapStr), sysCapObj) != 0) { + PRINT_ERR("Faill to add JSON items.\n"); goto ADD_JSON_FAILED; } // save as json file diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 9b97b79..43b3489 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -705,7 +705,6 @@ static int32_t ReleaseRpcidPriSyscappcidAndPriSyscapMemory(int32_t ret, char *pc return -1; } - int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t type) { int32_t ret; -- Gitee From 78aa295101510bf58c74a7425613df773c0bf610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=B9=8F=E6=98=8A?= Date: Fri, 2 Aug 2024 09:11:58 +0000 Subject: [PATCH 7/8] fix: Modify format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨鹏昊 --- include/create_pcid.h | 1 + src/create_pcid.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/create_pcid.h b/include/create_pcid.h index f2cf99c..67827b1 100644 --- a/include/create_pcid.h +++ b/include/create_pcid.h @@ -37,6 +37,7 @@ typedef struct PcidHeader { uint32_t manufacturerID; } PCIDHeader; +void SafeFree(void *ptr); int32_t CreatePCID(char *inputFile, char *outDirPath); int32_t DecodePCID(char *inputFile, char *outDirPath); int32_t DecodeStringPCIDToJson(char *input, char *outDirPath); diff --git a/src/create_pcid.c b/src/create_pcid.c index 85577be..8f4363d 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -67,7 +67,7 @@ struct FreeDecodePcidJsonInfo { int32_t flag; }; -void safeFree(void *ptr) { +void SafeFree(void *ptr) { if (ptr != NULL) { free(ptr); ptr = NULL; -- Gitee From 589f28e3fdd7ce7c3a913986c827867c2b8121e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=B9=8F=E6=98=8A?= Date: Fri, 2 Aug 2024 09:33:05 +0000 Subject: [PATCH 8/8] fix: Modify format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨鹏昊 --- src/create_pcid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index 8f4363d..220a55b 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -67,12 +67,13 @@ struct FreeDecodePcidJsonInfo { int32_t flag; }; -void SafeFree(void *ptr) { +void SafeFree(void *ptr) +{ if (ptr != NULL) { free(ptr); ptr = NULL; } -} +} int32_t SetOsSyscap(PCIDMain *pcidBuffer, uint32_t osCapSize, const cJSON *jsonOsSyscapObj, const cJSON *allOsSyscapObj) @@ -542,7 +543,7 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) char *strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj); if (strJson == NULL) { - PRINT_ERR("cJSON_Print failed to generate JSON string\n"); + PRINT_ERR("cJSON_Print failed to generate JSON string\n"); return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONVERT_OUT, -1); } -- Gitee