From 0fc798459ecb91cfe38b1ebf2abdc850ef39c960 Mon Sep 17 00:00:00 2001 From: liuhaotian Date: Tue, 7 Nov 2023 18:02:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81=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: liuhaotian Change-Id: I8a257aaa07eab15e30e6bc0de5fa3c1b3163523d --- interfaces/innerkits/native/file_share/src/file_share.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/native/file_share/src/file_share.cpp b/interfaces/innerkits/native/file_share/src/file_share.cpp index 4962f79c3..7218eb734 100644 --- a/interfaces/innerkits/native/file_share/src/file_share.cpp +++ b/interfaces/innerkits/native/file_share/src/file_share.cpp @@ -276,7 +276,11 @@ static int32_t CreateSingleShareFile(const string &uri, uint32_t tokenId, uint32 } for (size_t i = 0; i < info.sharePath_.size(); i++) { - if ((ret = open(info.sharePath_[i].c_str(), O_RDONLY | O_CREAT)) < 0) { + if (!SandboxHelper::CheckValidPath(info.sharePath_[i])) { + LOGE("Invalid share path with %{private}s", info.sharePath_[i].c_str()); + return -EINVAL; + } + if ((ret = open(info.sharePath_[i].c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) < 0) { LOGE("Create file failed with %{public}d", errno); return -errno; } -- Gitee