diff --git a/src/create_pcid.c b/src/create_pcid.c index cea4e574037ce2d8db10aa1fc76c6d40e8155a94..4ba2733a61437ed81f2e4aab52d670fcafc9dc6c 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -356,6 +356,11 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL 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 -1; + } if (*ptrPrivateSyscap == ',') { *tempPriSyscapStr = '\0'; int32_t ret = sprintf_s(fullCapStr, SINGLE_SYSCAP_LEN, "SystemCapability.%s", priSyscapStr);