diff --git a/src/create_pcid.c b/src/create_pcid.c index da299fe77dc9004582e5ae4320bc7a3338b4f379..c5e5bed4109dc91ff88f10776ad3444b3ac602e2 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) { + PRINT_ERR("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);