From 5f453a3731649943fd50c6b95486ded6898e36d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Thu, 20 Mar 2025 15:08:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9appspawn=20=E5=91=8A?= =?UTF-8?q?=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- modules/sandbox/appspawn_sandbox.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/sandbox/appspawn_sandbox.c b/modules/sandbox/appspawn_sandbox.c index 71ccba88..71dd2e1f 100644 --- a/modules/sandbox/appspawn_sandbox.c +++ b/modules/sandbox/appspawn_sandbox.c @@ -290,11 +290,13 @@ static int32_t SandboxMountFusePath(const SandboxContext *context, const MountAr APPSPAWN_CHECK(fd != -1, return -EINVAL, "open /dev/fuse failed, errno: %{public}d sandbox path %{public}s", errno, args->destinationPath); - char options[FUSE_OPTIONS_MAX_LEN]; - (void)sprintf_s(options, sizeof(options), "fd=%d," + char options[OPTIONS_MAX_LEN] = {0}; + int ret = sprintf_s(options, sizeof(options), "fd=%d," "rootmode=40000,user_id=%d,group_id=%d,allow_other," "context=\"u:object_r:dlp_fuse_file:s0\"," "fscontext=u:object_r:dlp_fuse_file:s0", fd, info->uid, info->gid); + APPSPAWN_CHECK(ret > 0, close(fd); + return APPSPAWN_ERROR_UTILS_MEM_FAIL, "sprintf options fail"); APPSPAWN_LOGV("Bind mount dlp fuse \n " "mount arg: '%{public}s' '%{public}s' %{public}x '%{public}s' %{public}s => %{public}s", @@ -304,7 +306,7 @@ static int32_t SandboxMountFusePath(const SandboxContext *context, const MountAr // To make sure destinationPath exist CreateSandboxDir(args->destinationPath, FILE_MODE); MountArg mountArg = {args->originPath, args->destinationPath, args->fsType, args->mountFlags, options, MS_SHARED}; - int ret = SandboxMountPath(&mountArg); + ret = SandboxMountPath(&mountArg); if (ret != 0) { close(fd); return -1; -- Gitee