From 9bcb7bb787d40bcd06b46519925a4d8003582193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=BA=E4=BC=9F?= Date: Thu, 11 Apr 2024 13:34:23 +0800 Subject: [PATCH 1/4] =?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: 张智伟 --- interfaces/kits/rust/BUILD.gn | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interfaces/kits/rust/BUILD.gn b/interfaces/kits/rust/BUILD.gn index 70cce3197..17ae73d9a 100644 --- a/interfaces/kits/rust/BUILD.gn +++ b/interfaces/kits/rust/BUILD.gn @@ -13,6 +13,10 @@ import("//build/ohos.gni") +config("public_config") { + include_dirs = [ "include/rust_file.h" ] +} + ohos_rust_shared_ffi("rust_file") { crate_type = "cdylib" part_name = "file_api" @@ -22,4 +26,5 @@ ohos_rust_shared_ffi("rust_file") { deps = [ "//third_party/rust/crates/libc:lib" ] external_deps = [ "hilog:hilog_rust" ] innerapi_tags = [ "platformsdk" ] + public_configs = [ ":public_config" ] } -- Gitee From 2909c3f39c1e601787ef7eec69a0493bfd3ca894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=BA=E4=BC=9F?= Date: Thu, 11 Apr 2024 13:37:18 +0800 Subject: [PATCH 2/4] =?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: 张智伟 --- interfaces/kits/native/fileio/fileio_native.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interfaces/kits/native/fileio/fileio_native.cpp b/interfaces/kits/native/fileio/fileio_native.cpp index 8a040ddf8..918f4387c 100644 --- a/interfaces/kits/native/fileio/fileio_native.cpp +++ b/interfaces/kits/native/fileio/fileio_native.cpp @@ -75,6 +75,9 @@ namespace { int GetFileLocation(char *uri, int uriLength, int *location) { + if (uri == nullptr) { + return -EINVAL; + } std::string uriStr(uri, uriLength); AppFileService::ModuleFileUri::FileUri fileUri(uriStr); int ret = GetLocationFromPath(fileUri.GetRealPath()); -- Gitee From 2abac5b0b709c0beb43f27e1cd96e584656aaf40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=BA=E4=BC=9F?= Date: Thu, 11 Apr 2024 15:25:55 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=8A=A0=E5=88=A4=E7=A9=BA=E3=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张智伟 --- interfaces/kits/native/fileio/fileio_native.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/native/fileio/fileio_native.cpp b/interfaces/kits/native/fileio/fileio_native.cpp index 918f4387c..60c4685c8 100644 --- a/interfaces/kits/native/fileio/fileio_native.cpp +++ b/interfaces/kits/native/fileio/fileio_native.cpp @@ -75,7 +75,7 @@ namespace { int GetFileLocation(char *uri, int uriLength, int *location) { - if (uri == nullptr) { + if (uri == nullptr || location == nullptr) { return -EINVAL; } std::string uriStr(uri, uriLength); -- Gitee From 63225a6fdd8bd3b4caf19ac1f0d22ca1d65defb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=BA=E4=BC=9F?= Date: Fri, 12 Apr 2024 09:00:29 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张智伟 --- interfaces/kits/native/fileio/fileio_native.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/native/fileio/fileio_native.cpp b/interfaces/kits/native/fileio/fileio_native.cpp index 60c4685c8..e07bdf286 100644 --- a/interfaces/kits/native/fileio/fileio_native.cpp +++ b/interfaces/kits/native/fileio/fileio_native.cpp @@ -75,7 +75,7 @@ namespace { int GetFileLocation(char *uri, int uriLength, int *location) { - if (uri == nullptr || location == nullptr) { + if (uri == nullptr || location == nullptr || uriLength <= 0 || uriLength > PATH_MAX) { return -EINVAL; } std::string uriStr(uri, uriLength); -- Gitee