diff --git a/test/fuzztest/remotefileshare_fuzzer/BUILD.gn b/test/fuzztest/remotefileshare_fuzzer/BUILD.gn index e787b85ef2706c0a14c03b5eb3666dc943f456e6..1771b5e0084dc7c962615c109459584e979b3d9e 100644 --- a/test/fuzztest/remotefileshare_fuzzer/BUILD.gn +++ b/test/fuzztest/remotefileshare_fuzzer/BUILD.gn @@ -17,9 +17,14 @@ import("//build/test.gni") ##############################fuzztest########################################## ohos_fuzztest("RemoteFileShareFuzzTest") { - module_out_path = "filemanagement/app_file_service" + module_out_path = "filemanagement/app_file_service/remotefileshare_test" fuzz_config_file = "//foundation/filemanagement/app_file_service/test/fuzztest/remotefileshare_fuzzer" - include_dirs = [] + include_dirs = [ + "include", + "../../../interfaces/innerkits/remote_file_share/native", + "//utils/system/safwk/native/include", + "//commonlibrary/c_utils/base/include", + ] cflags = [ "-g", "-O0", @@ -29,6 +34,7 @@ ohos_fuzztest("RemoteFileShareFuzzTest") { sources = [ "remotefileshare_fuzzer.cpp" ] deps = [ "//foundation/distributeddatamgr/distributedfile/utils/filemgmt_libn", + "../../../interfaces/innerkits/remote_file_share/native:remote_file_share_native", "//third_party/bounds_checking_function:libsec_shared", ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] diff --git a/test/fuzztest/remotefileshare_fuzzer/remotefileshare_fuzzer.cpp b/test/fuzztest/remotefileshare_fuzzer/remotefileshare_fuzzer.cpp index c47b367c473b69a2be68d55936ff1b345cd18ad4..051a25662bceec373bee61c3f06d42d333d38ee1 100644 --- a/test/fuzztest/remotefileshare_fuzzer/remotefileshare_fuzzer.cpp +++ b/test/fuzztest/remotefileshare_fuzzer/remotefileshare_fuzzer.cpp @@ -25,6 +25,7 @@ #include #include "securec.h" +#include "remote_file_share.h" namespace OHOS { namespace AppFileService { @@ -178,6 +179,22 @@ bool ShareFilePathIoctlFdFuzzTest(const uint8_t* data, size_t size) return true; } + +bool CreateShareFilePathFuzzTest(const uint8_t* data, size_t size) +{ + const int fd = *(reinterpret_cast(data)); + if (fd == -1) { + return false; + } + const int userId = *(reinterpret_cast(data)); + const std::string deviceId(std::string((const char *)data, size)); + std::string sharePath = ""; + int ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId, deviceId); + if (ret != 0) { + return false; + } + return true; +} } // namespace ModuleRemoteFileShare } // namespace AppFileService } // namespace OHOS @@ -189,5 +206,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::AppFileService::ModuleRemoteFileShare::ShareFilePathIoctlFdFuzzTest(data, size); OHOS::AppFileService::ModuleRemoteFileShare::ShareFilePathIoctlCidFuzzTest(data, size); OHOS::AppFileService::ModuleRemoteFileShare::ShareFilePathIoctlFdAndCidFuzzTest(data, size); + OHOS::AppFileService::ModuleRemoteFileShare::CreateShareFilePathFuzzTest(data, size); return 0; }