!474 告警清理,确保有符号整数运算不溢出

Merge pull request !474 from 严学舟/master
This commit is contained in:
openharmony_ci
2024-08-08 11:37:41 +00:00
committed by Gitee
+2 -7
View File
@@ -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);