From 4853cf195cc22f9f6fc02d8c7d69938197318be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=85=B6=E6=96=87?= Date: Thu, 21 Nov 2024 20:22:13 +0800 Subject: [PATCH] =?UTF-8?q?Appspawn=20Fuzz=E7=94=A8=E4=BE=8B=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ι™ˆε…Άζ–‡ --- .../appspawnclient_fuzzer.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/fuzztest/appspawnclient_fuzzer/appspawnclient_fuzzer.cpp b/test/fuzztest/appspawnclient_fuzzer/appspawnclient_fuzzer.cpp index 58dd09f1..1c874185 100644 --- a/test/fuzztest/appspawnclient_fuzzer/appspawnclient_fuzzer.cpp +++ b/test/fuzztest/appspawnclient_fuzzer/appspawnclient_fuzzer.cpp @@ -20,16 +20,16 @@ namespace OHOS { int FuzzAppSpawnClientInit(const uint8_t *data, size_t size) { - const char *name = APPSPAWN_SERVER_NAME; + std::string serviceName(reinterpret_cast(data), size); AppSpawnClientHandle handle = nullptr; - return AppSpawnClientInit(name, &handle); + return AppSpawnClientInit(serviceName.c_str(), &handle); } int FuzzAppSpawnClientDestroy(const uint8_t *data, size_t size) { - const char *name = APPSPAWN_SERVER_NAME; + std::string serviceName(reinterpret_cast(data), size); AppSpawnClientHandle handle = nullptr; - if (AppSpawnClientInit(name, &handle) != 0) { + if (AppSpawnClientInit(serviceName.c_str(), &handle) != 0) { return -1; } return AppSpawnClientDestroy(handle); @@ -277,7 +277,12 @@ namespace OHOS { int FuzzGetMaxPermissionIndex(const uint8_t *data, size_t size) { - return GetMaxPermissionIndex(nullptr); + std::string serviceName(reinterpret_cast(data), size); + AppSpawnClientHandle handle = nullptr; + if (AppSpawnClientInit(serviceName.c_str(), &handle) != 0) { + return -1; + } + return GetMaxPermissionIndex(handle); } int FuzzGetPermissionByIndex(const uint8_t *data, size_t size)