From 1ef672aafc64386d0002767a0d1d94a49b7537ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Fri, 25 Jul 2025 12:05:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- modules/common/appspawn_namespace.c | 6 +----- modules/sandbox/normal/sandbox_shared_mount.cpp | 7 +++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/common/appspawn_namespace.c b/modules/common/appspawn_namespace.c index 74ae78e1..8b230a14 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 fe9f1453..63a02377 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; -- Gitee