diff --git a/modules/common/appspawn_namespace.c b/modules/common/appspawn_namespace.c index 74ae78e1815912c34544657a1329a132276e6394..8b230a14d53e2ba053e20c9d9f54354c9f7700c8 100644 --- a/modules/common/appspawn_namespace.c +++ b/modules/common/appspawn_namespace.c @@ -128,11 +128,7 @@ APPSPAWN_STATIC pid_t GetPidByName(const char *name) continue; } size_t newline_pos = strcspn(buffer, "\n"); - if (newline_pos < sizeof(buffer) -1) { - buffer[newline_pos] = '\0'; - } else { - buffer[sizeof(buffer) -1] = '\0'; - } + APPSPAWN_CHECK_ONLY_EXPER(newline_pos >= sizeof(buffer), buffer[newline_pos] = 0); if (strcmp(buffer, name) != 0) { (void)fclose(file); continue; diff --git a/modules/sandbox/normal/sandbox_shared_mount.cpp b/modules/sandbox/normal/sandbox_shared_mount.cpp index fe9f145350f5deb8a46f4ff859a19e5fbc693beb..63a023775d60d38b0c4fcb29105da543e48a4238 100644 --- a/modules/sandbox/normal/sandbox_shared_mount.cpp +++ b/modules/sandbox/normal/sandbox_shared_mount.cpp @@ -489,10 +489,9 @@ static int ParseDataGroupList(AppSpawnMgr *content, const AppSpawningCtx *proper { int ret = 0; cJSON *dataGroupList = GetJsonObjFromExtInfo(property, DATA_GROUP_SOCKET_TYPE); - if (dataGroupList == nullptr || !cJSON_IsArray(dataGroupList)) { - APPSPAWN_LOGE("dataGroupList is empty"); - return APPSPAWN_ARG_INVALID; - } + APPSPAWN_CHECK(dataGroupList != nullptr, return APPSPAWN_ARG_INVALID, "dataGroupList is empty"); + APPSPAWN_CHECK(cJSON_IsArray(dataGroupList), cJSON_Delete(dataGroupList); + return APPSPAWN_ARG_INVALID, "dataGroupList is not Array"); // Iterate through the array (assuming groups is an array) cJSON *item = nullptr;