From ad306711a07bac71a260b7cba10e83f5bde8d2e3 Mon Sep 17 00:00:00 2001 From: kaiju Date: Mon, 23 Jun 2025 17:38:53 +0800 Subject: [PATCH] fix: fuzz crash Signed-off-by: kaiju Change-Id: I60eefd26c8eab77e5f89c006fd4a68122bf696df --- .../user_auth_driver_manager_fuzzer.cpp | 46 ++----------------- .../co_auth_service_fuzzer.cpp | 1 - 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/test/fuzztest/executors/userauthdrivermanager_fuzzer/user_auth_driver_manager_fuzzer.cpp b/test/fuzztest/executors/userauthdrivermanager_fuzzer/user_auth_driver_manager_fuzzer.cpp index 85dbbb58d..7cf98d903 100644 --- a/test/fuzztest/executors/userauthdrivermanager_fuzzer/user_auth_driver_manager_fuzzer.cpp +++ b/test/fuzztest/executors/userauthdrivermanager_fuzzer/user_auth_driver_manager_fuzzer.cpp @@ -223,65 +223,25 @@ void FuzzStart(std::shared_ptr parcel) IAM_LOGI("begin"); // driver manager forbids multiple invoke of Start(), it's config must be valid Singleton::GetInstance().Start(GLOBAL_HDI_NAME_TO_CONFIG); - Singleton::GetInstance().SubscribeHdiDriverStatus(); - IAM_LOGI("end"); -} - -void FuzzOnFrameworkReady(std::shared_ptr parcel) -{ - IAM_LOGI("begin"); Singleton::GetInstance().OnFrameworkReady(); - IAM_LOGI("end"); -} - -void FuzzOnAllHdiDisconnect(std::shared_ptr parcel) -{ - IAM_LOGI("begin"); - Singleton::GetInstance().OnAllHdiDisconnect(); - IAM_LOGI("end"); -} - -void FuzzGetDriverByServiceName(std::shared_ptr parcel) -{ - IAM_LOGI("begin"); + Singleton::GetInstance().SubscribeHdiDriverStatus(); std::string serviceName; parcel->ReadString(serviceName); Singleton::GetInstance().GetDriverByServiceName(serviceName); - IAM_LOGI("end"); -} - -void FuzzDriverConnect(std::shared_ptr parcel) -{ - IAM_LOGI("begin"); uint32_t index = parcel->ReadUint32() % (sizeof(GLOBAL_SERVICE_NAMES) / sizeof(GLOBAL_SERVICE_NAMES[0])); std::shared_ptr driver = Singleton::GetInstance().GetDriverByServiceName(GLOBAL_SERVICE_NAMES[index]); // Since config is valid, GetDriverByServiceName should never return null. // If it happens to be null, let fuzz process crash. driver->OnHdiConnect(); - IAM_LOGI("end"); -} - -void FuzzDriverDisconnect(std::shared_ptr parcel) -{ - IAM_LOGI("begin"); - uint32_t index = parcel->ReadUint32() % (sizeof(GLOBAL_SERVICE_NAMES) / sizeof(GLOBAL_SERVICE_NAMES[0])); - std::shared_ptr driver = - Singleton::GetInstance().GetDriverByServiceName(GLOBAL_SERVICE_NAMES[index]); - // Since config is valid, GetDriverByServiceName should never return null. - // If it happens to be null, let fuzz process crash. driver->OnHdiDisconnect(); + Singleton::GetInstance().OnAllHdiDisconnect(); IAM_LOGI("end"); } -using FuzzFunc = decltype(FuzzGetDriverByServiceName); +using FuzzFunc = decltype(FuzzStart); FuzzFunc *g_fuzzFuncs[] = { FuzzStart, - FuzzOnFrameworkReady, - FuzzOnAllHdiDisconnect, - FuzzGetDriverByServiceName, - FuzzDriverConnect, - FuzzDriverDisconnect, }; void UserAuthDriverManagerFuzzTest(const uint8_t *data, size_t size) diff --git a/test/fuzztest/services/coauthservice_fuzzer/co_auth_service_fuzzer.cpp b/test/fuzztest/services/coauthservice_fuzzer/co_auth_service_fuzzer.cpp index 8319148e7..768751452 100644 --- a/test/fuzztest/services/coauthservice_fuzzer/co_auth_service_fuzzer.cpp +++ b/test/fuzztest/services/coauthservice_fuzzer/co_auth_service_fuzzer.cpp @@ -156,7 +156,6 @@ void FuzzOther(Parcel &parcel) AuthType authType = static_cast(parcel.ReadInt32()); ExecutorRole executorRole = static_cast(parcel.ReadInt32()); g_coAuthService->AddExecutorDeathRecipient(executorIndex, authType, executorRole, callback); - g_coAuthService->OnStart(); g_coAuthService->OnStop(); IAM_LOGI("end"); } -- Gitee