diff --git a/interfaces/kits/native/fileio/fileio_native.cpp b/interfaces/kits/native/fileio/fileio_native.cpp index 8a040ddf8a76bd500bdf5aa7d5bf06de2de2ee34..e07bdf28613d8ec3201cbb6159b22399c75be795 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 || location == nullptr || uriLength <= 0 || uriLength > PATH_MAX) { + return -EINVAL; + } std::string uriStr(uri, uriLength); AppFileService::ModuleFileUri::FileUri fileUri(uriStr); int ret = GetLocationFromPath(fileUri.GetRealPath()); diff --git a/interfaces/kits/rust/BUILD.gn b/interfaces/kits/rust/BUILD.gn index 70cce319774c8d69e57f75ddd5bdb402843f7727..17ae73d9a648e923455559ef691bf8e2c3c33f2c 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" ] }