diff --git a/test/fuzztest/remotefileshare_fuzzer/BUILD.gn b/test/fuzztest/remotefileshare_fuzzer/BUILD.gn index e787b85ef2706c0a14c03b5eb3666dc943f456e6..148396150efbb22203e83e26116657238a543891 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", @@ -28,6 +33,7 @@ ohos_fuzztest("RemoteFileShareFuzzTest") { ] sources = [ "remotefileshare_fuzzer.cpp" ] deps = [ + "../../../interfaces/innerkits/remote_file_share/native:remote_file_share_native", "//foundation/distributeddatamgr/distributedfile/utils/filemgmt_libn", "//third_party/bounds_checking_function:libsec_shared", ] diff --git a/test/fuzztest/remotefileshare_fuzzer/corpus/init b/test/fuzztest/remotefileshare_fuzzer/corpus/init index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..56a8849ff560eba917e8538700dabd62ceff9bd7 100644 --- a/test/fuzztest/remotefileshare_fuzzer/corpus/init +++ b/test/fuzztest/remotefileshare_fuzzer/corpus/init @@ -13,4 +13,5 @@ * limitations under the License. */ -FUZZ \ No newline at end of file +FUZZ +12 sharePath 100 \ No newline at end of file diff --git a/test/fuzztest/remotefileshare_fuzzer/remotefileshare_fuzzer.cpp b/test/fuzztest/remotefileshare_fuzzer/remotefileshare_fuzzer.cpp index c47b367c473b69a2be68d55936ff1b345cd18ad4..1d40c2c4d3fb2b35f458794d19a1f3158d0e6a73 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,21 @@ 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)); + std::string sharePath = ""; + int ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId); + if (ret != 0) { + return false; + } + return true; +} } // namespace ModuleRemoteFileShare } // namespace AppFileService } // namespace OHOS @@ -189,5 +205,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; }