diff --git a/src/create_pcid.c b/src/create_pcid.c index ef2764f9b8b4e755e6fc669bd3a383ff7eae0715..11240264bc05edccb069c7b530592911cd9a56e7 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -379,6 +379,11 @@ static int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, int32_t con char *tempPriSyscapStr = priSyscapStr; char *ptrPrivateSyscap = (char *)(pcidMain + 1); while (*ptrPrivateSyscap != '\0') { + size_t currentLen = tempPriSyscapStr - priSyscapStr; + if (currentLen >= SINGLE_SYSCAP_LEN - 1) { + printf("Syscap name exceeds maximum length\n"); + return GetPriSyscapResult(capVectorPtr, -1); + } if (*ptrPrivateSyscap == ',') { *tempPriSyscapStr = '\0'; int32_t ret = sprintf_s(fullCapStr, SINGLE_SYSCAP_LEN, "SystemCapability.%s", priSyscapStr);