diff --git a/src/create_pcid.c b/src/create_pcid.c index c2aa7e7406ded7ee33206db77a16268275bdb2f7..36f0f20e4d1d80ce289f15ad93df7b4557d22396 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -359,7 +359,7 @@ static int32_t GetPriSyscapResult(cJSON *capVectorPtr, int32_t ret) return ret; } -int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufLen) +static int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, int32_t contextBufLen) { cJSON *capVectorPtr = cJSON_CreateArray(); if (capVectorPtr == NULL) { @@ -367,12 +367,7 @@ 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); + int32_t privateSyscapLen = contextBufLen - sizeof(PCIDMain) - 1; if (privateSyscapLen < 0 || privateSyscapLen > INT32_MAX) { PRINT_ERR("parse private syscap failed."); return GetPriSyscapResult(capVectorPtr, -1); @@ -527,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";