diff --git a/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp b/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp index 325ef2c4cef66d1fb93f199ef77baf22f8b2844d..e23981b624b7ab473ed99e64bd2cf19e5328835a 100644 --- a/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp +++ b/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.cpp @@ -18,7 +18,10 @@ #include "wificdevice_fuzzer.h" #include "wifi_fuzz_common_func.h" #include "kits/c/wifi_device.h" +#include +static FuzzedDataProvider *FDP = nullptr; +static const int32_t NUM_BYTES = 1; static void EnableWifiTest() { @@ -40,311 +43,213 @@ static void DisconnectTest() { Disconnect(); } -static void RemoveDeviceTest(const uint8_t* data, size_t size) +static void RemoveDeviceTest() { - if (size == 0) { - return; - } - int networkId = static_cast(data[0]); + int networkId = FDP->ConsumeIntegral(); RemoveDevice(networkId); } -static void DisableDeviceConfigTest(const uint8_t* data, size_t size) +static void DisableDeviceConfigTest() { - if (size == 0) { - return; - } - int networkId = static_cast(data[0]); + int networkId = FDP->ConsumeIntegral(); DisableDeviceConfig(networkId); } -static void EnableDeviceConfigTest(const uint8_t* data, size_t size) +static void EnableDeviceConfigTest() { - if (size == 0) { - return; - } - int networkId = static_cast(data[0]); + int networkId = FDP->ConsumeIntegral(); EnableDeviceConfig(networkId); } -static void ConnectToTest(const uint8_t* data, size_t size) +static void ConnectToTest() { - if (size == 0) { - return; - } - int networkId = static_cast(data[0]); + int networkId = FDP->ConsumeIntegral(); ConnectTo(networkId); } -static void AddDeviceConfigTest(const uint8_t* data, size_t size) +static void AddDeviceConfigTest() { - int index = 0; WifiDeviceConfig config; - if (size >= sizeof(WifiDeviceConfig)) { - if (memcpy_s(config.ssid, WIFI_MAX_SSID_LEN, data, WIFI_MAX_SSID_LEN - 1) != EOK) { - return; - } - if (memcpy_s(config.bssid, WIFI_MAC_LEN, data, WIFI_MAC_LEN - 1) != EOK) { - return; - } - if (memcpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, data, WIFI_MAX_KEY_LEN - 1) != EOK) { - return; - } - config.securityType = static_cast(data[index++]); - config.netId = static_cast(data[index++]); - config.freq = static_cast(data[index++]); - config.wapiPskType = static_cast(data[index++]); - config.isHiddenSsid = static_cast(data[index++]); - config.ipType = static_cast(static_cast(data[index++]) % TWO); - } - int result = static_cast(data[index++]); + std::string ssid_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(config.ssid, sizeof(config.ssid), ssid_str.c_str()); + std::vector bssid_vec = FDP->ConsumeBytes(NUM_BYTES); + memcpy_s(config.bssid, sizeof(config.bssid), bssid_vec.data(), bssid_vec.size()); + std::string preSharedKey_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(config.preSharedKey, sizeof(config.ssid), preSharedKey_str.c_str()); + config.securityType = FDP->ConsumeIntegral(); + config.netId = FDP->ConsumeIntegral(); + config.freq = FDP->ConsumeIntegral(); + config.wapiPskType = FDP->ConsumeIntegral(); + config.isHiddenSsid = FDP->ConsumeIntegral(); + config.ipType = static_cast(FDP->ConsumeIntegral() % TWO); + int result = FDP->ConsumeIntegral(); AddDeviceConfig(&config, &result); } -static void AdvanceScanTest(const uint8_t* data, size_t size) +static void AdvanceScanTest() { WifiScanParams params; - if (size >= sizeof(WifiScanParams)) { - if (memcpy_s(params.ssid, WIFI_MAX_SSID_LEN, data, WIFI_MAX_SSID_LEN - 1) != EOK) { - return; - } - if (memcpy_s(params.bssid, WIFI_MAC_LEN, data, WIFI_MAC_LEN - 1) != EOK) { - return; - } - int index = 0; - params.scanType = WIFI_FREQ_SCAN; - params.freqs = static_cast(data[index++]); - params.band = static_cast(data[index++]); - params.ssidLen = static_cast(data[index++]); - } + std::string ssid_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(params.ssid, sizeof(params.ssid), ssid_str.c_str()); + std::vector bssid_vec = FDP->ConsumeBytes(NUM_BYTES); + memcpy_s(params.bssid, sizeof(params.bssid), bssid_vec.data(), bssid_vec.size()); + params.scanType = static_cast(FDP->ConsumeIntegral() % FOUR); + params.freqs = FDP->ConsumeIntegral(); + params.band = FDP->ConsumeIntegral(); + params.ssidLen = FDP->ConsumeIntegral(); AdvanceScan(¶ms); } -static void GetSignalLevelTest(const uint8_t* data, size_t size) +static void GetSignalLevelTest() { - int rssi = 0; - int band = 0; - if (size >= TWO) { - int index = 0; - rssi = static_cast(data[index++]); - band = static_cast(data[index++]); - } + int rssi = FDP->ConsumeIntegral(); + int band = FDP->ConsumeIntegral(); GetSignalLevel(rssi, band); } -static void GetScanInfoListTest(const uint8_t* data, size_t size) +static void GetScanInfoListTest() { WifiScanInfo result; - unsigned int mSize; - if (size >= sizeof(WifiScanInfo)) { - if (memcpy_s(result.ssid, WIFI_MAX_SSID_LEN, data, WIFI_MAX_SSID_LEN - 1) != EOK) { - return; - } - - if (memcpy_s(result.bssid, WIFI_MAC_LEN, data + WIFI_MAX_SSID_LEN, WIFI_MAC_LEN) != EOK) { - return; - } - int index = 0; - result.securityType = static_cast(data[index++]); - result.rssi = static_cast(data[index++]); - result.band = static_cast(data[index++]); - result.frequency = static_cast(data[index++]); - result.channelWidth = static_cast(static_cast(data[index++]) % WIDTH_INVALID); - result.centerFrequency0 = static_cast(data[index++]); - result.centerFrequency1 = static_cast(data[index++]); - result.timestamp = static_cast(OHOS::Wifi::U32_AT(data)); - mSize = static_cast(data[0]); - } + std::string ssid_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(result.ssid, sizeof(result.ssid), ssid_str.c_str()); + std::vector bssid_vec = FDP->ConsumeBytes(NUM_BYTES); + memcpy_s(result.bssid, sizeof(result.bssid), bssid_vec.data(), bssid_vec.size()); + result.securityType = FDP->ConsumeIntegral(); + result.rssi = FDP->ConsumeIntegral(); + result.band = FDP->ConsumeIntegral(); + result.frequency = FDP->ConsumeIntegral(); + result.channelWidth = static_cast(FDP->ConsumeIntegralInRange(0, WIDTH_INVALID)); + result.centerFrequency0 = FDP->ConsumeIntegral(); + result.centerFrequency1 = FDP->ConsumeIntegral(); + result.timestamp = FDP->ConsumeIntegral(); + unsigned int mSize = FDP->ConsumeIntegral(); (void)GetScanInfoList(&result, &mSize); } -static void GetDeviceConfigsTest(const uint8_t* data, size_t size) +static void GetDeviceConfigsTest() { WifiDeviceConfig result; - unsigned int mSize; - if (size >= sizeof(WifiDeviceConfig)) { - if (memcpy_s(result.ssid, WIFI_MAX_SSID_LEN, data, WIFI_MAX_SSID_LEN - 1) != EOK) { - return; - } - - if (memcpy_s(result.bssid, WIFI_MAC_LEN, data + WIFI_MAX_SSID_LEN, WIFI_MAC_LEN) != EOK) { - return; - } - - if (memcpy_s(result.preSharedKey, WIFI_MAX_KEY_LEN, data + WIFI_MAX_SSID_LEN, WIFI_MAX_KEY_LEN - 1) != EOK) { - return; - } - int index = 0; - result.securityType = static_cast(data[index++]); - result.netId = static_cast(data[index++]); - result.freq = static_cast(data[index++]); - result.wapiPskType = static_cast(data[index++]); - result.ipType = static_cast(static_cast(data[index++]) % UNKNOWN); - result.staticIp.ipAddress = static_cast(data[index++]); - result.staticIp.gateway = static_cast(data[index++]); - result.staticIp.netmask = static_cast(data[index++]); - result.isHiddenSsid = static_cast(data[index++]); - mSize = static_cast(data[0]); - } + std::string ssid_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(result.ssid, sizeof(result.ssid), ssid_str.c_str()); + std::vector bssid_vec = FDP->ConsumeBytes(NUM_BYTES); + memcpy_s(result.bssid, sizeof(result.bssid), bssid_vec.data(), bssid_vec.size()); + std::string preSharedKey_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(result.preSharedKey, sizeof(result.ssid), preSharedKey_str.c_str()); + result.securityType = FDP->ConsumeIntegral(); + result.netId = FDP->ConsumeIntegral(); + result.freq = FDP->ConsumeIntegral(); + result.wapiPskType = FDP->ConsumeIntegral(); + result.ipType = static_cast(FDP->ConsumeIntegral() % UNKNOWN); + result.staticIp.ipAddress = FDP->ConsumeIntegral(); + result.staticIp.gateway = FDP->ConsumeIntegral(); + result.staticIp.netmask = FDP->ConsumeIntegral(); + result.isHiddenSsid = FDP->ConsumeIntegral(); + unsigned int mSize = FDP->ConsumeIntegral(); (void)GetDeviceConfigs(&result, &mSize); } -static void ConnectToDeviceTest(const uint8_t* data, size_t size) +static void ConnectToDeviceTest() { WifiDeviceConfig config; - if (size >= sizeof(WifiDeviceConfig)) { - if (memcpy_s(config.ssid, WIFI_MAX_SSID_LEN, data, WIFI_MAX_SSID_LEN - 1) != EOK) { - return; - } - - if (memcpy_s(config.bssid, WIFI_MAC_LEN, data + WIFI_MAX_SSID_LEN, WIFI_MAC_LEN) != EOK) { - return; - } - - if (memcpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, data + WIFI_MAX_SSID_LEN, WIFI_MAX_KEY_LEN - 1) != EOK) { - return; - } - int index = 0; - config.securityType = static_cast(data[index++]); - config.netId = static_cast(data[index++]); - config.freq = static_cast(data[index++]); - config.wapiPskType = static_cast(data[index++]); - config.ipType = static_cast(static_cast(data[index++]) % UNKNOWN); - config.staticIp.ipAddress = static_cast(data[index++]); - config.staticIp.gateway = static_cast(data[index++]); - config.staticIp.netmask = static_cast(data[index++]); - config.isHiddenSsid = static_cast(data[index++]); - } + std::string ssid_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(config.ssid, sizeof(config.ssid), ssid_str.c_str()); + std::vector bssid_vec = FDP->ConsumeBytes(NUM_BYTES); + memcpy_s(config.bssid, sizeof(config.bssid), bssid_vec.data(), bssid_vec.size()); + std::string preSharedKey_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(config.preSharedKey, sizeof(config.ssid), preSharedKey_str.c_str()); + config.securityType = FDP->ConsumeIntegral(); + config.netId = FDP->ConsumeIntegral(); + config.freq = FDP->ConsumeIntegral(); + config.wapiPskType = FDP->ConsumeIntegral(); + config.isHiddenSsid = FDP->ConsumeIntegral(); + config.ipType = static_cast(FDP->ConsumeIntegral() % UNKNOWN); + config.staticIp.ipAddress = FDP->ConsumeIntegral(); + config.staticIp.gateway = FDP->ConsumeIntegral(); + config.staticIp.netmask = FDP->ConsumeIntegral(); + config.isHiddenSsid = FDP->ConsumeIntegral(); (void)ConnectToDevice(&config); } -static void GetLinkedInfoTest(const uint8_t* data, size_t size) +static void GetLinkedInfoTest() { WifiLinkedInfo result; - if (size >= sizeof(WifiLinkedInfo)) { - if (memcpy_s(result.ssid, WIFI_MAX_SSID_LEN, data, WIFI_MAX_SSID_LEN - 1) != EOK) { - return; - } - - if (memcpy_s(result.bssid, WIFI_MAC_LEN, data + WIFI_MAX_SSID_LEN, WIFI_MAC_LEN) != EOK) { - return; - } - int index = 0; - result.rssi = static_cast(data[index++]); - result.band = static_cast(data[index++]); - result.frequency = static_cast(data[index++]); - result.connState = static_cast(static_cast(data[index++]) % (WIFI_CONNECTED + 1)); - result.disconnectedReason = static_cast(data[index++]); - result.ipAddress = static_cast(data[index++]); - } + std::string ssid_str = FDP->ConsumeBytesAsString(NUM_BYTES); + strcpy_s(result.ssid, sizeof(result.ssid), ssid_str.c_str()); + std::vector bssid_vec = FDP->ConsumeBytes(NUM_BYTES); + memcpy_s(result.bssid, sizeof(result.bssid), bssid_vec.data(), bssid_vec.size()); + result.frequency = FDP->ConsumeIntegral(); + result.connState = static_cast(FDP->ConsumeIntegral() % (WIFI_CONNECTED + 1)); + result.disconnectedReason = FDP->ConsumeIntegral(); + result.ipAddress = FDP->ConsumeIntegral(); (void)GetLinkedInfo(&result); } -static void GetDeviceMacAddressTest(const uint8_t* data, size_t size) +static void GetDeviceMacAddressTest() { - unsigned char result; - if (size > 0) { - result = static_cast(data[0]); - } + unsigned char result = FDP->ConsumeIntegral(); (void)GetDeviceMacAddress(&result); } -static void GetWifiDetailStateTest(const uint8_t* data, size_t size) +static void GetWifiDetailStateTest() { - WifiDetailState state; - if (size > 0) { - state = static_cast(data[0]); - } + WifiDetailState state = static_cast(FDP->ConsumeIntegralInRange(-1, 5)); (void)GetWifiDetailState(&state); } -static void GetIpInfoTest(const uint8_t* data, size_t size) +static void GetIpInfoTest() { IpInfo info; - if (size >= sizeof(IpInfo)) { - int index = 0; - info.ipAddress = static_cast(data[index++]); - info.netMask = static_cast(data[index++]); - info.netGate = static_cast(data[index++]); - info.dns1 = static_cast(data[index++]); - info.dns2 = static_cast(data[index++]); - info.serverAddress = static_cast(data[index++]); - info.leaseDuration = static_cast(data[index++]); - } + info.ipAddress = FDP->ConsumeIntegral(); + info.netMask = FDP->ConsumeIntegral(); + info.netGate = FDP->ConsumeIntegral(); + info.dns1 = FDP->ConsumeIntegral(); + info.dns2 = FDP->ConsumeIntegral(); + info.serverAddress = FDP->ConsumeIntegral(); + info.leaseDuration = FDP->ConsumeIntegral(); (void)GetIpInfo(&info); } -static void SetLowLatencyModeTest(const uint8_t* data, size_t size) +static void SetLowLatencyModeTest() { - int enabled = 0; - if (size == 0) { - return; - } - enabled = static_cast(data[0]); + int enabled = FDP->ConsumeIntegral(); (void)SetLowLatencyMode(enabled); } -static void Get5GHzChannelListTest(const uint8_t* data, size_t size) +static void Get5GHzChannelListTest() { - int result = 0; - int sizet = 0; - if (size >= TWO) { - int index = 0; - result = static_cast(data[index++]); - sizet = static_cast(data[index++]); - } + int result = FDP->ConsumeIntegral(); + int sizet = FDP->ConsumeIntegral(); (void)Get5GHzChannelList(&result, &sizet); } -static void IsBandTypeSupportedTest(const uint8_t* data, size_t size) +static void IsBandTypeSupportedTest() { - bool supported = true; - int bandType = static_cast(data[0]); + bool supported = FDP->ConsumeBool(); + int bandType = FDP->ConsumeIntegral(); (void)IsBandTypeSupported(bandType, &supported); } -static void IsRandomMacDisabledTest(const uint8_t* data, size_t size) -{ - bool isRandomMacDisabled = false; - if (size == 0) { - return; - } - isRandomMacDisabled = (static_cast(data[0]) % TWO) ? true : false; - (void)IsRandomMacDisabled(&isRandomMacDisabled); -} - -static void SetRandomMacDisabledTest(const uint8_t* data, size_t size) -{ - bool isRandomMacDisabled = false; - if (size == 0) { - return; - } - isRandomMacDisabled = (static_cast(data[0]) % TWO) ? true : false; - (void)SetRandomMacDisabled(isRandomMacDisabled); -} namespace OHOS { namespace Wifi { - bool WifiCDeviceFuzzerTest(const uint8_t* data, size_t size) + bool WifiCDeviceFuzzerTest() { EnableWifiTest(); DisableWifiTest(); EnableSemiWifiTest(); ScanTest(); - RemoveDeviceTest(data, size); - DisableDeviceConfigTest(data, size); - EnableDeviceConfigTest(data, size); - ConnectToTest(data, size); + RemoveDeviceTest(); + DisableDeviceConfigTest(); + EnableDeviceConfigTest(); + ConnectToTest(); DisconnectTest(); - AddDeviceConfigTest(data, size); - AdvanceScanTest(data, size); - GetSignalLevelTest(data, size); + AddDeviceConfigTest(); + AdvanceScanTest(); + GetSignalLevelTest(); (void)IsWifiActive(); - GetScanInfoListTest(data, size); - GetDeviceConfigsTest(data, size); - ConnectToDeviceTest(data, size); - GetLinkedInfoTest(data, size); - GetDeviceMacAddressTest(data, size); - GetWifiDetailStateTest(data, size); - GetIpInfoTest(data, size); - SetLowLatencyModeTest(data, size); - Get5GHzChannelListTest(data, size); - IsBandTypeSupportedTest(data, size); - SetRandomMacDisabledTest(data, size); - IsRandomMacDisabledTest(data, size); + GetScanInfoListTest(); + GetDeviceConfigsTest(); + ConnectToDeviceTest(); + GetLinkedInfoTest(); + GetDeviceMacAddressTest(); + GetWifiDetailStateTest(); + GetIpInfoTest(); + SetLowLatencyModeTest(); + Get5GHzChannelListTest(); + IsBandTypeSupportedTest(); return true; } } // namespace Wifi @@ -352,7 +257,9 @@ namespace Wifi { /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - OHOS::Wifi::WifiCDeviceFuzzerTest(data, size); + FuzzedDataProvider fdp(data, size); + FDP = &fdp; + OHOS::Wifi::WifiCDeviceFuzzerTest(); return 0; } diff --git a/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.h b/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.h index 10f561a5f17a4d089122cc20095892b9d056d27c..a2c725a497bb6f4f50a5d765f025e87570544e75 100755 --- a/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.h +++ b/wifi/test/fuzztest/frameworks/native/c_adapter/wificdevice_fuzzer/wificdevice_fuzzer.h @@ -19,4 +19,5 @@ #define FUZZ_PROJECT_NAME "wificdevice_fuzzer" #define TWO 2 +#define FOUR 4 #endif diff --git a/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/corpus/init b/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/corpus/init index ece6c3f6682247c918a86ec01505bdfcb64cc19d..a5d20a4ada7022a7bef7bb9d108402d59ac35574 100644 --- a/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/corpus/init +++ b/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/corpus/init @@ -13,4 +13,14 @@ * limitations under the License. */ -FUZZ \ No newline at end of file +FUZZ +WIFI_CBK_MSG_STATE_CHANGE 0x1001 +WIFI_CBK_MSG_CONNECTION_CHANGE 0x1002 +WIFI_CBK_MSG_RSSI_CHANGE 0x1003 +WIFI_CBK_MSG_STREAM_DIRECTION 0x1004 +WIFI_CBK_MSG_WPS_STATE_CHANGE 0x1005 +WIFI_CBK_MSG_DEVICE_CONFIG_CHANGE 0x1006 +WIFI_CBK_MSG_SEMI_STATE_CHANGE 0x1007 +WIFI_CBK_MSG_INTERNET_ACCESS_CHANGE 0x1008 +WIFI_CBK_MSG_CANDIDATE_CONNECT_CHANGE 0x1009 +WIFI_CBK_MSG_MAX_INVALID_STA 0x1FFF \ No newline at end of file diff --git a/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/wifiap_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/wifiap_fuzzer.cpp index f451040618defe4c72cbf262a0374661ec298112..de514f9cf75fbe680b23d186c07641ba3cdb0c5a 100644 --- a/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/wifiap_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/wifiap_fuzzer.cpp @@ -14,6 +14,7 @@ */ #include "wifiap_fuzzer.h" +#include #include #include @@ -38,6 +39,8 @@ constexpr int TWO = 2; constexpr int THREE = 3; constexpr int U32_AT_SIZE_ZERO = 4; constexpr int SIX = 6; +FuzzedDataProvider *FDP = nullptr; +static const int32_t NUM_BYTES = 1; MockPendant *pMockPendant = new MockPendant(); std::shared_ptr pApService = std::make_shared(pMockPendant->GetMockApStateMachine(), @@ -125,14 +128,14 @@ void WifiApRootStateFuzzTest(const uint8_t* data, size_t size) pApRootState->ExecuteStateMsg(msg); } -void BlockListAndStationFuzzTest(const uint8_t* data, size_t size) +void BlockListAndStationFuzzTest() { StationInfo staInfo; - int index = 0; - staInfo.deviceName = std::string(reinterpret_cast(data), size); - staInfo.bssid = std::string(reinterpret_cast(data), size); - staInfo.bssidType = static_cast(data[index++]); - staInfo.ipAddr = std::string(reinterpret_cast(data), size); + staInfo.deviceName = FDP->ConsumeBytesAsString(NUM_BYTES); + staInfo.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + staInfo.bssidType = FDP->ConsumeIntegral(); + staInfo.ipAddr = FDP->ConsumeBytesAsString(NUM_BYTES); + pApStationsManager->AddBlockList(staInfo); pApStationsManager->DelBlockList(staInfo); pApStationsManager->StationJoin(staInfo); @@ -323,6 +326,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) if ((data == nullptr) || (size <= OHOS::Wifi::U32_AT_SIZE_ZERO)) { return 0; } + FuzzedDataProvider fdp(data, size); + OHOS::Wifi::FDP = &fdp; OHOS::Wifi::UpdateApChannelConfigFuzzTest(data, size); OHOS::Wifi::GetBestChannelFor2GFuzzTest(data, size); OHOS::Wifi::GetBestChannelFor5GFuzzTest(data, size); @@ -332,8 +337,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Wifi::JudgeDbacWithP2pFuzzTest(data, size); OHOS::Wifi::GetIndoorChanByCountryCodeFuzzTest(data, size); OHOS::Wifi::GetPreferredChannelByBandFuzzTest(data, size); + OHOS::Wifi::BlockListAndStationFuzzTest(); OHOS::Wifi::WifiApRootStateFuzzTest(data, size); - OHOS::Wifi::BlockListAndStationFuzzTest(data, size); OHOS::Wifi::EnableAllBlockListFuzzTest(data, size); OHOS::Wifi::StationLeaveFuzzTest(data, size); OHOS::Wifi::GetAllConnectedStationsFuzzTest(data, size); diff --git a/wifi/test/fuzztest/wifi_sta/wifidevicestub_fuzzer/wifidevicestub_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifidevicestub_fuzzer/wifidevicestub_fuzzer.cpp index f255309e280fc48316eb62449efaf35bc6f490b4..c03ef1706f7c113af42b09455be312280a1b88be 100644 --- a/wifi/test/fuzztest/wifi_sta/wifidevicestub_fuzzer/wifidevicestub_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifidevicestub_fuzzer/wifidevicestub_fuzzer.cpp @@ -15,6 +15,7 @@ #include "wifidevicestub_fuzzer.h" #include "wifi_fuzz_common_func.h" +#include #include #include @@ -37,8 +38,8 @@ namespace OHOS { namespace Wifi { -constexpr size_t U32_AT_SIZE_ZERO = 4; -constexpr int TWO = 2; +FuzzedDataProvider *FDP = nullptr; +const int32_t NUM_BYTES = 1; constexpr int FIVE = 5; constexpr int NINE = 9; static bool g_isInsted = false; @@ -124,663 +125,773 @@ bool OnRemoteRequest(uint32_t code, MessageParcel &data) return true; } -void OnInitWifiProtectFuzzTest(const uint8_t* data, size_t size) +void OnInitWifiProtectFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_INIT_WIFI_PROTECT), datas); } -void OnGetWifiProtectRefFuzzTest(const uint8_t* data, size_t size) +void OnGetWifiProtectRefFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_WIFI_PROTECT), datas); } -void OnPutWifiProtectRefFuzzTest(const uint8_t* data, size_t size) +void OnPutWifiProtectRefFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_PUT_WIFI_PROTECT), datas); } -void OnIsHeldWifiProtectRefFuzzTest(const uint8_t* data, size_t size) +void OnIsHeldWifiProtectRefFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_HELD_WIFI_PROTECT), datas); } -void OnAddDeviceConfigFuzzTest(const uint8_t* data, size_t size) +void OnAddDeviceConfigFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_ADD_DEVICE_CONFIG), datas); } -void OnUpdateDeviceConfigFuzzTest(const uint8_t* data, size_t size) +void OnUpdateDeviceConfigFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_UPDATE_DEVICE_CONFIG), datas); } -void OnRemoveDeviceFuzzTest(const uint8_t* data, size_t size) +void OnRemoveDeviceFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_REMOVE_DEVICE_CONFIG), datas); } -void OnRemoveAllDeviceFuzzTest(const uint8_t* data, size_t size) +void OnRemoveAllDeviceFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_REMOVE_ALL_DEVICE_CONFIG), datas); } -void OnGetDeviceConfigsFuzzTest(const uint8_t* data, size_t size) +void OnGetDeviceConfigsFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIGS), datas); } -void OnEnableDeviceConfigFuzzTest(const uint8_t* data, size_t size) +void OnEnableDeviceConfigFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_DEVICE), datas); } -void OnDisableDeviceConfigFuzzTest(const uint8_t* data, size_t size) +void OnDisableDeviceConfigFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_DISABLE_DEVICE), datas); } -void OnConnectToFuzzTest(const uint8_t* data, size_t size) +void OnConnectToFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_CONNECT_TO), datas); } -void OnConnect2ToFuzzTest(const uint8_t* data, size_t size) +void OnConnect2ToFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_CONNECT2_TO), datas); } -void OnReConnectFuzzTest(const uint8_t* data, size_t size) +void OnReConnectFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_RECONNECT), datas); } -void OnReAssociateFuzzTest(const uint8_t* data, size_t size) +void OnReAssociateFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_REASSOCIATE), datas); } -void OnDisconnectFuzzTest(const uint8_t* data, size_t size) +void OnDisconnectFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_DISCONNECT), datas); } -void OnStartWpsFuzzTest(const uint8_t* data, size_t size) +void OnStartWpsFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_START_WPS), datas); } -void OnCancelWpsFuzzTest(const uint8_t* data, size_t size) +void OnCancelWpsFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_CANCEL_WPS), datas); } -void OnIsWifiActiveFuzzTest(const uint8_t* data, size_t size) +void OnIsWifiActiveFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_WIFI_ACTIVE), datas); } -void OnGetWifiStateFuzzTest(const uint8_t* data, size_t size) +void OnGetWifiStateFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_WIFI_STATE), datas); } -void OnGetLinkedInfoFuzzTest(const uint8_t* data, size_t size) +void OnGetLinkedInfoFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_LINKED_INFO), datas); } -void OnIsMeteredHotspotFuzzTest(const uint8_t* data, size_t size) +void OnIsMeteredHotspotFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_METERED_HOTSPOT), datas); } -void OnGetIpInfoFuzzTest(const uint8_t* data, size_t size) +void OnGetIpInfoFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_DHCP_INFO), datas); } -void OnSetCountryCodeFuzzTest(const uint8_t* data, size_t size) +void OnSetCountryCodeFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_COUNTRY_CODE), datas); } -void OnGetCountryCodeFuzzTest(const uint8_t* data, size_t size) +void OnGetCountryCodeFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_COUNTRY_CODE), datas); } -void OnRegisterCallBackFuzzTest(const uint8_t* data, size_t size) +void OnRegisterCallBackFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_REGISTER_CALLBACK_CLIENT), datas); } -void OnGetSignalLevelFuzzTest(const uint8_t* data, size_t size) +void OnGetSignalLevelFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_SIGNAL_LEVEL), datas); } -void OnGetIpV6InfoFuzzTest(const uint8_t* data, size_t size) +void OnGetIpV6InfoFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_DHCP_IPV6INFO), datas); } -void OnGetDeviceMacAddFuzzTest(const uint8_t* data, size_t size) +void OnGetDeviceMacAddFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_DERVICE_MAC_ADD), datas); } -void OnIsWifiConnectedFuzzTest(const uint8_t* data, size_t size) +void OnIsWifiConnectedFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_WIFI_CONNECTED), datas); } -void OnSetLowLatencyModeFuzzTest(const uint8_t* data, size_t size) +void OnSetLowLatencyModeFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_LOW_LATENCY_MODE), datas); } -void OnRemoveCandidateConfigFuzzTest(const uint8_t* data, size_t size) +void OnRemoveCandidateConfigFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_REMOVE_CANDIDATE_CONFIG), datas); } -void OnIsBandTypeSupportedFuzzTest(const uint8_t* data, size_t size) +void OnIsBandTypeSupportedFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_BANDTYPE_SUPPORTED), datas); } -void OnGet5GHzChannelListFuzzTest(const uint8_t* data, size_t size) +void OnGet5GHzChannelListFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_5G_CHANNELLIST), datas); } -void OnGetDisconnectedReasonFuzzTest(const uint8_t* data, size_t size) +void OnGetDisconnectedReasonFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_DISCONNECTED_REASON), datas); } -void OnSetFrozenAppFuzzTest(const uint8_t* data, size_t size) +void OnSetFrozenAppFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_FROZEN_APP), datas); } -void OnResetAllFrozenAppFuzzTest(const uint8_t* data, size_t size) +void OnResetAllFrozenAppFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_RESET_ALL_FROZEN_APP), datas); } -void OnDisableAutoJoinFuzzTest(const uint8_t* data, size_t size) +void OnDisableAutoJoinFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_DISABLE_AUTO_JOIN), datas); } -void OnEnableAutoJoinFuzzTest(const uint8_t* data, size_t size) +void OnEnableAutoJoinFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_AUTO_JOIN), datas); } -void OnStartPortalCertificationFuzzTest(const uint8_t* data, size_t size) +void OnStartPortalCertificationFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_START_PORTAL_CERTIF), datas); } -void OnGetChangeDeviceConfigFuzzTest(const uint8_t* data, size_t size) +void OnGetChangeDeviceConfigFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIG_CHANGE), datas); } -void OnLimitSpeedFuzzTest(const uint8_t* data, size_t size) +void OnLimitSpeedFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_LIMIT_SPEED), datas); } -void OnEnableHiLinkHandshakeFuzzTest(const uint8_t* data, size_t size) +void OnEnableHiLinkHandshakeFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_HILINK_CONNECT), datas); } -void OnStartWifiDetectionFuzzTest(const uint8_t* data, size_t size) +void OnStartWifiDetectionFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_START_WIFI_DETECTION), datas); } -void OnSetSatelliteStateFuzzTest(const uint8_t* data, size_t size) +void OnSetSatelliteStateFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_SATELLITE_STATE), datas); } -void OnFactoryResetFuzzTest(const uint8_t* data, size_t size) +void OnFactoryResetFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_SET_FACTORY_RESET), datas); } -void OnEnableWifiFuzzTest(const uint8_t* data, size_t size) +void OnEnableWifiFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_WIFI), datas); } -void OnDisableWifiFuzzTest(const uint8_t* data, size_t size) +void OnDisableWifiFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_DISABLE_WIFI), datas); } -void OnGetSupportedFeaturesFuzzTest(const uint8_t* data, size_t size) +void OnGetSupportedFeaturesFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_SUPPORTED_FEATURES), datas); } -void OnEnableSemiWifiFuzzTest(const uint8_t* data, size_t size) +void OnEnableSemiWifiFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_SEMI_WIFI), datas); } -void OnGetWifiDetailStateFuzzTest(const uint8_t* data, size_t size) +void OnGetWifiDetailStateFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_WIFI_DETAIL_STATE), datas); } -void OnSetTxPowerFuzzTest(const uint8_t* data, size_t size) +void OnSetTxPowerFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_TX_POWER), datas); } -void OnSetLowTxPowerTest(const uint8_t* data, size_t size) +void OnSetLowTxPowerTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_LOW_TX_POWER), datas); } -void OnSetDpiMarkRuleTest(const uint8_t* data, size_t size) +void OnSetDpiMarkRuleTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_DPI_MARK_RULE), datas); } -void DoSomethingDeviceMgrStubTest(const uint8_t* data, size_t size) +void DoSomethingDeviceMgrStubTest() { std::string networkName = "backup"; std::string name = "restore"; uint32_t code = static_cast(DevInterfaceCode::WIFI_MGR_GET_DEVICE_SERVICE); MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE_EX); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); datas.RewindRead(0); MessageParcel reply; MessageOption option; @@ -795,26 +906,25 @@ bool WifiFuzzTest() return true; } -void WifiDeviceServiceImplTest(const uint8_t* data, size_t size) +void WifiDeviceServiceImplTest() { - int index = 0; - int networkId = static_cast(data[index++]); - int uid = static_cast(data[index++]); - std::string networkName = std::string(reinterpret_cast(data), size); - FilterTag filterTag = static_cast(static_cast(data[0]) % FIVE); - bool attemptEnable = (static_cast(data[0]) % TWO) ? true : false; + int networkId = FDP->ConsumeIntegral(); + int uid = FDP->ConsumeIntegral(); + std::string networkName = FDP->ConsumeBytesAsString(NUM_BYTES); + FilterTag filterTag = static_cast(FDP->ConsumeIntegral() % FIVE); + bool attemptEnable = FDP->ConsumeBool(); WifiDeviceServiceImpl mWifiDeviceServiceImpl; MessageParcel datas; WifiDeviceConfig config; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); mWifiDeviceServiceImpl.DeregisterAutoJoinCondition(networkName); mWifiDeviceServiceImpl.DeregisterFilterBuilder(filterTag, networkName); @@ -830,19 +940,18 @@ void WifiDeviceServiceImplTest(const uint8_t* data, size_t size) pWifiDeviceStub->WriteWifiDeviceConfig(datas, config); } -void CheckConfigEapTest(const uint8_t* data, size_t size) +void CheckConfigEapTest() { WifiDeviceConfig config; - int index = 0; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); std::string keyMgmtWapiPsk = "WPA-PSK"; config.keyMgmt = keyMgmtWapiPsk; pWifiDeviceServiceImpl->CheckConfigEap(config); @@ -850,160 +959,152 @@ void CheckConfigEapTest(const uint8_t* data, size_t size) std::string eapMethodPeap = "PEAP"; config.wifiEapConfig.eap = EAP_METHOD_PEAP; pWifiDeviceServiceImpl->CheckConfigEap(config); - config.keyMgmt = std::string(reinterpret_cast(data), size); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); pWifiDeviceServiceImpl->CheckConfigEap(config); } -void CheckConfigWapiTest(const uint8_t* data, size_t size) +void CheckConfigWapiTest() { WifiDeviceConfig config; - int index = 0; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); std::string keyMgmtwapiPsk = "WAPI-PSK"; config.keyMgmt = keyMgmtwapiPsk; pWifiDeviceServiceImpl->CheckConfigWapi(config); config.keyMgmt.clear(); - config.keyMgmt = std::string(reinterpret_cast(data), size); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); pWifiDeviceServiceImpl->CheckConfigWapi(config); } -void CheckConfigPwdTest(const uint8_t* data, size_t size) +void CheckConfigPwdTest() { WifiDeviceConfig config; - int index = 0; std::string ssidLength = "name"; config.ssid = ssidLength; - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); pWifiDeviceServiceImpl->CheckConfigPwd(config); } -void InitWifiBrokerProcessInfoTest(const uint8_t* data, size_t size) +void InitWifiBrokerProcessInfoTest() { WifiDeviceConfig config; - int index = 0; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); std::string ancoServiceBroker = "anco_service_broker"; config.callProcessName = ancoServiceBroker; pWifiDeviceServiceImpl->InitWifiBrokerProcessInfo(config); } -void SetWifiConnectedModeTest(const uint8_t* data, size_t size) +void SetWifiConnectedModeTest() { pWifiDeviceServiceImpl->SetWifiConnectedMode(); } -void RemoveCandidateConfigFuzzTest(const uint8_t* data, size_t size) +void RemoveCandidateConfigFuzzTest() { WifiDeviceConfig config; - int index = 0; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); - config.callProcessName = std::string(reinterpret_cast(data), size); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); + config.callProcessName = FDP->ConsumeBytesAsString(NUM_BYTES); pWifiDeviceServiceImpl->RemoveCandidateConfig(config); } -void RemoveCandidateConfigTest(const uint8_t* data, size_t size) +void RemoveCandidateConfigTest() { - int index = 0; - int networkId = static_cast(data[index++]); + int networkId = FDP->ConsumeIntegral(); pWifiDeviceServiceImpl->RemoveCandidateConfig(networkId); } -void AddDeviceConfigTest(const uint8_t* data, size_t size) +void AddDeviceConfigTest() { WifiDeviceConfig config; int result = 0; - int index = 0; - bool isCandidate = (static_cast(data[0]) % TWO) ? true : false; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); - config.callProcessName = std::string(reinterpret_cast(data), size); + bool isCandidate = FDP->ConsumeBool(); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); + config.callProcessName = FDP->ConsumeBytesAsString(NUM_BYTES); pWifiDeviceServiceImpl->AddDeviceConfig(config, result, isCandidate); } -void ConnectToNetworkTest(const uint8_t* data, size_t size) +void ConnectToNetworkTest() { - int index = 0; - int networkId = static_cast(data[index++]); - bool isCandidate = (static_cast(data[0]) % TWO) ? true : false; + int networkId = FDP->ConsumeIntegral(); + bool isCandidate = FDP->ConsumeBool(); pWifiDeviceServiceImpl->ConnectToNetwork(networkId, isCandidate); } -void ConnectToDeviceTest(const uint8_t* data, size_t size) +void ConnectToDeviceTest() { WifiDeviceConfig config; - int index = 0; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); pWifiDeviceServiceImpl->ConnectToDevice(config); } -void SaBasicDumpTest(const uint8_t* data, size_t size) +void SaBasicDumpTest() { WifiLinkedInfo info; - info.connState = static_cast(static_cast(data[0]) % NINE); + info.connState = static_cast(FDP->ConsumeIntegral() % NINE); WifiConfigCenter::GetInstance().SaveLinkedInfo(info, 0); std::string result; pWifiDeviceServiceImpl->SaBasicDump(result); } -void IsRemoteDiedTest(const uint8_t* data, size_t size) +void IsRemoteDiedTest() { pWifiDeviceServiceImpl->IsRemoteDied(); } -void IsBandTypeSupportedTest(const uint8_t* data, size_t size) +void IsBandTypeSupportedTest() { - int bandType = static_cast(data[0]); - bool supported = (static_cast(data[0]) % TWO) ? true : false; + int bandType = FDP->ConsumeIntegral(); + bool supported = FDP->ConsumeBool(); pWifiDeviceServiceImpl->IsBandTypeSupported(bandType, supported); } -void RegisterCallBackTest(const uint8_t* data, size_t size) +void RegisterCallBackTest() { std::vector event; sptr callBack = new (std::nothrow) IWifiDeviceCallBackMock(); @@ -1011,279 +1112,277 @@ void RegisterCallBackTest(const uint8_t* data, size_t size) pWifiDeviceServiceImpl->RegisterCallBack(nullptr, event); } -void CheckCanEnableWifiTest(const uint8_t* data, size_t size) +void CheckCanEnableWifiTest() { pWifiDeviceServiceImpl->CheckCanEnableWifi(); } -void HilinkGetMacAddressTest(const uint8_t* data, size_t size) +void HilinkGetMacAddressTest() { WifiDeviceConfig config; - int index = 0; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); - std::string currentMac = std::string(reinterpret_cast(data), size); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string currentMac = FDP->ConsumeBytesAsString(NUM_BYTES); pWifiDeviceServiceImpl->HilinkGetMacAddress(config, currentMac); } -void EnableHiLinkHandshakeTest(const uint8_t* data, size_t size) +void EnableHiLinkHandshakeTest() { WifiDeviceConfig config; - int index = 0; - config.ssid = std::string(reinterpret_cast(data), size); - config.bssid = std::string(reinterpret_cast(data), size); - config.preSharedKey = std::string(reinterpret_cast(data), size); - config.keyMgmt = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.eap = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.clientCert = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.privateKey = std::string(reinterpret_cast(data), size); - config.wifiEapConfig.certEntry.push_back(static_cast(data[index++])); - config.wifiEapConfig.encryptedData = std::string(reinterpret_cast(data), size); - bool uiFlag = (static_cast(data[0]) % TWO) ? true : false; - std::string bssid = std::string(reinterpret_cast(data), size); + config.ssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.bssid = FDP->ConsumeBytesAsString(NUM_BYTES); + config.preSharedKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.keyMgmt = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.eap = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.clientCert = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.privateKey = FDP->ConsumeBytesAsString(NUM_BYTES); + config.wifiEapConfig.certEntry.push_back(FDP->ConsumeIntegral()); + config.wifiEapConfig.encryptedData = FDP->ConsumeBytesAsString(NUM_BYTES); + bool uiFlag = FDP->ConsumeBool(); + std::string bssid = FDP->ConsumeBytesAsString(NUM_BYTES); pWifiDeviceServiceImpl->EnableHiLinkHandshake(uiFlag, bssid, config); } -void StartWifiDetectionTest(const uint8_t* data, size_t size) +void StartWifiDetectionTest() { pWifiDeviceServiceImpl->StartWifiDetection(); } -void RegisterFilterBuilderTest(const uint8_t* data, size_t size) +void RegisterFilterBuilderTest() { - FilterTag filterTag = static_cast(static_cast(data[0]) % FIVE); - std::string bssid = std::string(reinterpret_cast(data), size); + FilterTag filterTag = static_cast(FDP->ConsumeIntegral() % FIVE); + std::string bssid = FDP->ConsumeBytesAsString(NUM_BYTES); FilterBuilder filterBuilder = [](auto &compositeWifiFilter) {}; pWifiDeviceServiceImpl->RegisterFilterBuilder(filterTag, bssid, filterBuilder); } -void OnGetDeviceConfigTest(const uint8_t* data, size_t size) +void OnGetDeviceConfigTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_DEVICE_CONFIG), datas); } -void OnIsFeatureSupportedTest(const uint8_t* data, size_t size) +void OnIsFeatureSupportedTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_FEATURE_SUPPORTED), datas); } -void OnUpdateNetworkLagInfoTest(const uint8_t* data, size_t size) +void OnUpdateNetworkLagInfoTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_NETWORK_LAG_INFO), datas); } -void OnReceiveNetworkControlInfoTest(const uint8_t* data, size_t size) +void OnReceiveNetworkControlInfoTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_NET_CONTROL_INFO), datas); } -void OnFetchWifiSignalInfoForVoWiFiTest(const uint8_t* data, size_t size) +void OnFetchWifiSignalInfoForVoWiFiTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_FETCH_SIGNALINFO_VOWIFI), datas); } -void OnIsSupportVoWifiDetectTest(const uint8_t* data, size_t size) +void OnIsSupportVoWifiDetectTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_SUPPORT_VOWIFI_DETECT), datas); } -void OnSetVoWifiDetectModeTest(const uint8_t* data, size_t size) +void OnSetVoWifiDetectModeTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_VOWIFI_DETECT_MODE), datas); } -void OnSetVoWifiDetectPeriodTest(const uint8_t* data, size_t size) +void OnSetVoWifiDetectPeriodTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_VOWIFI_DETECT_PERIOD), datas); } -void OnIsRandomMacDisabledTest(const uint8_t* data, size_t size) +void OnGetVoWifiDetectPeriodTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); - OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_RANDOMMAC_DISABLED), datas); -} - -void OnSetRandomMacDisabledTest(const uint8_t* data, size_t size) -{ - MessageParcel datas; - if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { - LOGE("WriteInterfaceToken failed!"); - return; - } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); - OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_SET_RANDOMMAC_DISABLED), datas); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); + OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_VOWIFI_DETECT_PERIOD), datas); } -void OnGetVoWifiDetectPeriodTest(const uint8_t* data, size_t size) -{ - MessageParcel datas; - if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { - LOGE("WriteInterfaceToken failed!"); - return; - } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); - OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_VOWIFI_DETECT_PERIOD), datas); +void WifiDeviceFuzzTest() +{ + OHOS::Wifi::OnInitWifiProtectFuzzTest(); + OHOS::Wifi::OnGetWifiProtectRefFuzzTest(); + OHOS::Wifi::OnPutWifiProtectRefFuzzTest(); + OHOS::Wifi::OnIsHeldWifiProtectRefFuzzTest(); + OHOS::Wifi::OnAddDeviceConfigFuzzTest(); + OHOS::Wifi::OnUpdateDeviceConfigFuzzTest(); + OHOS::Wifi::OnRemoveDeviceFuzzTest(); + OHOS::Wifi::OnRemoveAllDeviceFuzzTest(); + OHOS::Wifi::OnGetDeviceConfigsFuzzTest(); + OHOS::Wifi::OnEnableDeviceConfigFuzzTest(); + OHOS::Wifi::OnDisableDeviceConfigFuzzTest(); + OHOS::Wifi::OnConnectToFuzzTest(); + OHOS::Wifi::OnConnect2ToFuzzTest(); + OHOS::Wifi::OnReConnectFuzzTest(); + OHOS::Wifi::OnReAssociateFuzzTest(); + OHOS::Wifi::OnDisconnectFuzzTest(); + OHOS::Wifi::OnStartWpsFuzzTest(); + OHOS::Wifi::OnCancelWpsFuzzTest(); + OHOS::Wifi::OnIsWifiActiveFuzzTest(); + OHOS::Wifi::OnGetWifiStateFuzzTest(); + OHOS::Wifi::OnIsMeteredHotspotFuzzTest(); + OHOS::Wifi::OnGetLinkedInfoFuzzTest(); + OHOS::Wifi::OnGetIpInfoFuzzTest(); + OHOS::Wifi::OnGetCountryCodeFuzzTest(); + OHOS::Wifi::OnRegisterCallBackFuzzTest(); + OHOS::Wifi::OnGetSignalLevelFuzzTest(); + OHOS::Wifi::OnGetIpV6InfoFuzzTest(); + OHOS::Wifi::OnGetDeviceMacAddFuzzTest(); + OHOS::Wifi::OnIsWifiConnectedFuzzTest(); + OHOS::Wifi::OnSetLowLatencyModeFuzzTest(); + OHOS::Wifi::OnRemoveCandidateConfigFuzzTest(); + OHOS::Wifi::OnIsBandTypeSupportedFuzzTest(); + OHOS::Wifi::OnGet5GHzChannelListFuzzTest(); + OHOS::Wifi::OnGetDisconnectedReasonFuzzTest(); + OHOS::Wifi::OnSetFrozenAppFuzzTest(); + OHOS::Wifi::OnResetAllFrozenAppFuzzTest(); + OHOS::Wifi::OnDisableAutoJoinFuzzTest(); + OHOS::Wifi::OnEnableAutoJoinFuzzTest(); + OHOS::Wifi::OnStartPortalCertificationFuzzTest(); + OHOS::Wifi::OnGetChangeDeviceConfigFuzzTest(); + OHOS::Wifi::OnLimitSpeedFuzzTest(); + OHOS::Wifi::OnEnableHiLinkHandshakeFuzzTest(); + OHOS::Wifi::OnGetWifiDetailStateFuzzTest(); +} + +void WifiDeviceFuzzTestPart2() +{ + OHOS::Wifi::OnSetTxPowerFuzzTest(); + OHOS::Wifi::OnStartWifiDetectionFuzzTest(); + OHOS::Wifi::OnSetSatelliteStateFuzzTest(); + OHOS::Wifi::OnGetSupportedFeaturesFuzzTest(); + OHOS::Wifi::OnSetLowTxPowerTest(); + OHOS::Wifi::DoSomethingDeviceMgrStubTest(); + OHOS::Wifi::WifiDeviceServiceImplTest(); + OHOS::Wifi::CheckConfigEapTest(); + OHOS::Wifi::CheckConfigWapiTest(); + OHOS::Wifi::CheckConfigPwdTest(); + OHOS::Wifi::InitWifiBrokerProcessInfoTest(); + OHOS::Wifi::SetWifiConnectedModeTest(); + OHOS::Wifi::RemoveCandidateConfigFuzzTest(); + OHOS::Wifi::RemoveCandidateConfigTest(); + OHOS::Wifi::AddDeviceConfigTest(); + OHOS::Wifi::ConnectToNetworkTest(); + OHOS::Wifi::ConnectToDeviceTest(); + OHOS::Wifi::SaBasicDumpTest(); + OHOS::Wifi::IsRemoteDiedTest(); + OHOS::Wifi::IsBandTypeSupportedTest(); + OHOS::Wifi::RegisterCallBackTest(); + OHOS::Wifi::CheckCanEnableWifiTest(); + OHOS::Wifi::HilinkGetMacAddressTest(); + OHOS::Wifi::EnableHiLinkHandshakeTest(); + OHOS::Wifi::StartWifiDetectionTest(); + OHOS::Wifi::RegisterFilterBuilderTest(); + OHOS::Wifi::OnSetDpiMarkRuleTest(); + OHOS::Wifi::OnGetDeviceConfigTest(); + OHOS::Wifi::OnIsFeatureSupportedTest(); + OHOS::Wifi::OnUpdateNetworkLagInfoTest(); + OHOS::Wifi::OnReceiveNetworkControlInfoTest(); + OHOS::Wifi::OnFetchWifiSignalInfoForVoWiFiTest(); + OHOS::Wifi::OnIsSupportVoWifiDetectTest(); + OHOS::Wifi::OnSetVoWifiDetectModeTest(); + OHOS::Wifi::OnSetVoWifiDetectPeriodTest(); + OHOS::Wifi::OnGetVoWifiDetectPeriodTest(); } /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= OHOS::Wifi::U32_AT_SIZE_ZERO)) { - return 0; - } - OHOS::Wifi::OnInitWifiProtectFuzzTest(data, size); - OHOS::Wifi::OnGetWifiProtectRefFuzzTest(data, size); - OHOS::Wifi::OnPutWifiProtectRefFuzzTest(data, size); - OHOS::Wifi::OnIsHeldWifiProtectRefFuzzTest(data, size); - OHOS::Wifi::OnAddDeviceConfigFuzzTest(data, size); - OHOS::Wifi::OnUpdateDeviceConfigFuzzTest(data, size); - OHOS::Wifi::OnRemoveDeviceFuzzTest(data, size); - OHOS::Wifi::OnRemoveAllDeviceFuzzTest(data, size); - OHOS::Wifi::OnGetDeviceConfigsFuzzTest(data, size); - OHOS::Wifi::OnEnableDeviceConfigFuzzTest(data, size); - OHOS::Wifi::OnDisableDeviceConfigFuzzTest(data, size); - OHOS::Wifi::OnConnectToFuzzTest(data, size); - OHOS::Wifi::OnConnect2ToFuzzTest(data, size); - OHOS::Wifi::OnReConnectFuzzTest(data, size); - OHOS::Wifi::OnReAssociateFuzzTest(data, size); - OHOS::Wifi::OnDisconnectFuzzTest(data, size); - OHOS::Wifi::OnStartWpsFuzzTest(data, size); - OHOS::Wifi::OnCancelWpsFuzzTest(data, size); - OHOS::Wifi::OnIsWifiActiveFuzzTest(data, size); - OHOS::Wifi::OnGetWifiStateFuzzTest(data, size); - OHOS::Wifi::OnIsMeteredHotspotFuzzTest(data, size); - OHOS::Wifi::OnGetLinkedInfoFuzzTest(data, size); - OHOS::Wifi::OnGetIpInfoFuzzTest(data, size); - OHOS::Wifi::OnGetCountryCodeFuzzTest(data, size); - OHOS::Wifi::OnRegisterCallBackFuzzTest(data, size); - OHOS::Wifi::OnGetSignalLevelFuzzTest(data, size); - OHOS::Wifi::OnGetIpV6InfoFuzzTest(data, size); - OHOS::Wifi::OnGetDeviceMacAddFuzzTest(data, size); - OHOS::Wifi::OnIsWifiConnectedFuzzTest(data, size); - OHOS::Wifi::OnSetLowLatencyModeFuzzTest(data, size); - OHOS::Wifi::OnRemoveCandidateConfigFuzzTest(data, size); - OHOS::Wifi::OnIsBandTypeSupportedFuzzTest(data, size); - OHOS::Wifi::OnGet5GHzChannelListFuzzTest(data, size); - OHOS::Wifi::OnGetDisconnectedReasonFuzzTest(data, size); - OHOS::Wifi::OnSetFrozenAppFuzzTest(data, size); - OHOS::Wifi::OnResetAllFrozenAppFuzzTest(data, size); - OHOS::Wifi::OnDisableAutoJoinFuzzTest(data, size); - OHOS::Wifi::OnEnableAutoJoinFuzzTest(data, size); - OHOS::Wifi::OnStartPortalCertificationFuzzTest(data, size); - OHOS::Wifi::OnGetChangeDeviceConfigFuzzTest(data, size); - OHOS::Wifi::OnLimitSpeedFuzzTest(data, size); - OHOS::Wifi::OnEnableHiLinkHandshakeFuzzTest(data, size); - OHOS::Wifi::OnStartWifiDetectionFuzzTest(data, size); - OHOS::Wifi::OnGetWifiDetailStateFuzzTest(data, size); - OHOS::Wifi::OnSetTxPowerFuzzTest(data, size); - OHOS::Wifi::OnSetSatelliteStateFuzzTest(data, size); - OHOS::Wifi::OnGetSupportedFeaturesFuzzTest(data, size); - OHOS::Wifi::OnSetLowTxPowerTest(data, size); - OHOS::Wifi::DoSomethingDeviceMgrStubTest(data, size); - OHOS::Wifi::WifiDeviceServiceImplTest(data, size); - OHOS::Wifi::CheckConfigEapTest(data, size); - OHOS::Wifi::CheckConfigWapiTest(data, size); - OHOS::Wifi::CheckConfigPwdTest(data, size); - OHOS::Wifi::InitWifiBrokerProcessInfoTest(data, size); - OHOS::Wifi::SetWifiConnectedModeTest(data, size); - OHOS::Wifi::RemoveCandidateConfigFuzzTest(data, size); - OHOS::Wifi::RemoveCandidateConfigTest(data, size); - OHOS::Wifi::AddDeviceConfigTest(data, size); - OHOS::Wifi::ConnectToNetworkTest(data, size); - OHOS::Wifi::ConnectToDeviceTest(data, size); - OHOS::Wifi::SaBasicDumpTest(data, size); - OHOS::Wifi::IsRemoteDiedTest(data, size); - OHOS::Wifi::IsBandTypeSupportedTest(data, size); - OHOS::Wifi::RegisterCallBackTest(data, size); - OHOS::Wifi::CheckCanEnableWifiTest(data, size); - OHOS::Wifi::HilinkGetMacAddressTest(data, size); - OHOS::Wifi::EnableHiLinkHandshakeTest(data, size); - OHOS::Wifi::StartWifiDetectionTest(data, size); - OHOS::Wifi::RegisterFilterBuilderTest(data, size); - OHOS::Wifi::OnSetDpiMarkRuleTest(data, size); - OHOS::Wifi::OnGetDeviceConfigTest(data, size); - OHOS::Wifi::OnIsFeatureSupportedTest(data, size); - OHOS::Wifi::OnUpdateNetworkLagInfoTest(data, size); - OHOS::Wifi::OnReceiveNetworkControlInfoTest(data, size); - OHOS::Wifi::OnFetchWifiSignalInfoForVoWiFiTest(data, size); - OHOS::Wifi::OnIsSupportVoWifiDetectTest(data, size); - OHOS::Wifi::OnSetVoWifiDetectModeTest(data, size); - OHOS::Wifi::OnSetVoWifiDetectPeriodTest(data, size); - OHOS::Wifi::OnGetVoWifiDetectPeriodTest(data, size); - OHOS::Wifi::OnIsRandomMacDisabledTest(data, size); - OHOS::Wifi::OnSetRandomMacDisabledTest(data, size); - sleep(4); + FuzzedDataProvider fdp(data, size); + OHOS::Wifi::FDP = &fdp; + OHOS::Wifi::WifiDeviceFuzzTest(); + OHOS::Wifi::WifiDeviceFuzzTestPart2(); return 0; } } diff --git a/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/wifihotspotimpl_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/wifihotspotimpl_fuzzer.cpp index 468ec8b7cc8b7bdad0e2fc3a19f82be9177ab4fa..8edb42266e057a3a6a9db6fe7fff74197bbb93e6 100644 --- a/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/wifihotspotimpl_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/wifihotspotimpl_fuzzer.cpp @@ -15,7 +15,7 @@ #include "wifihotspotimpl_fuzzer.h" #include "wifi_fuzz_common_func.h" - +#include #include "wifi_hotspot_service_impl.h" #include "wifi_hotspot_mgr_stub.h" #include "wifi_hotspot_mgr_service_impl.h" @@ -30,6 +30,7 @@ #include namespace OHOS { namespace Wifi { +FuzzedDataProvider *FDP = nullptr; constexpr int BAND_WIFI_TYPES = 6; constexpr int IDLE_TIME_OUT_MAX = 60; constexpr int IPADDR_SEG_NUMS = 4; @@ -92,6 +93,7 @@ void SetHotspotConfigFuzzTest(const uint8_t* data, size_t size) std::vector band_5G_channel = { 149, 168, 169 }; ChannelsTable node{{ BandType::BAND_2GHZ, band_2G_channel }, { BandType::BAND_5GHZ, band_5G_channel }}; HotspotConfig config; + config.apBandWidth = FDP->ConsumeIntegral(); WifiChannelHelper::GetInstance().SetValidChannels(node); pWifiHotspotServiceImpl->SetHotspotConfig(config); } @@ -166,6 +168,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) if ((data == NULL) || (size < DATA_SIZE_MIN)) { return 0; } + FuzzedDataProvider fdp(data, size); + OHOS::Wifi::FDP = &fdp; OHOS::Wifi::TransRandomToRealMacFuzzTest(data, size); OHOS::Wifi::IsHotspotDualBandSupportedFuzzTest(data, size); OHOS::Wifi::IsOpenSoftApAllowedFuzzTest(data, size); diff --git a/wifi/test/fuzztest/wifi_sta/wifihotspotstub_fuzzer/wifihotspotstub_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifihotspotstub_fuzzer/wifihotspotstub_fuzzer.cpp index 414fd873feb6dce5869d2a051f34a548a98b0cc0..66f210884e4059d9fdde92171af4669b9b2b2b9e 100644 --- a/wifi/test/fuzztest/wifi_sta/wifihotspotstub_fuzzer/wifihotspotstub_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifihotspotstub_fuzzer/wifihotspotstub_fuzzer.cpp @@ -36,6 +36,7 @@ #include "wifi_common_def.h" #include "wifi_manager.h" #include "wifi_net_agent.h" +#include namespace OHOS { namespace Wifi { @@ -49,7 +50,8 @@ static std::mutex g_instanceLock; std::shared_ptr pWifiDeviceStub = std::make_shared(); std::shared_ptr pWifiHotspotServiceImpl = std::make_shared(); sptr pWifiHotspotMgrStub = WifiHotspotMgrServiceImpl::GetInstance(); - +FuzzedDataProvider *FDP = nullptr; +static const int32_t NUM_BYTES = 1; bool Init() { if (!g_isInsted) { @@ -77,301 +79,351 @@ bool OnRemoteRequest(uint32_t code, MessageParcel &data) return true; } -void OnIsHotspotActiveFuzzTest(const uint8_t* data, size_t size) +void OnIsHotspotActiveFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_IS_HOTSPOT_ACTIVE), datas); } -void OnGetApStateWifiFuzzTest(const uint8_t* data, size_t size) +void OnGetApStateWifiFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GETAPSTATE_WIFI), datas); } -void OnGetHotspotConfigFuzzTest(const uint8_t* data, size_t size) +void OnGetHotspotConfigFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GET_HOTSPOT_CONFIG), datas); } -void OnSetApConfigWifiFuzzTest(const uint8_t* data, size_t size) +void OnSetApConfigWifiFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_SETAPCONFIG_WIFI), datas); } -void OnGetStationListFuzzTest(const uint8_t* data, size_t size) +void OnGetStationListFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GET_STATION_LIST), datas); } -void OnAddBlockListFuzzTest(const uint8_t* data, size_t size) +void OnAddBlockListFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_ADD_BLOCK_LIST), datas); } -void OnDelBlockListFuzzTest(const uint8_t* data, size_t size) +void OnDelBlockListFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_DEL_BLOCK_LIST), datas); } -void OnGetBlockListsFuzzTest(const uint8_t* data, size_t size) +void OnGetBlockListsFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GET_BLOCK_LISTS), datas); } -void OnGetValidBandsFuzzTest(const uint8_t* data, size_t size) +void OnGetValidBandsFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GET_VALID_BANDS), datas); } -void OnDisassociateStaFuzzTest(const uint8_t* data, size_t size) +void OnDisassociateStaFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_DISCONNECT_STA), datas); } -void OnGetValidChannelsFuzzTest(const uint8_t* data, size_t size) +void OnGetValidChannelsFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GET_VALID_CHANNELS), datas); } -void OnRegisterCallBackFuzzTest(const uint8_t* data, size_t size) +void OnRegisterCallBackFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_REGISTER_HOTSPOT_CALLBACK), datas); } -void OnGetSupportedPowerModelFuzzTest(const uint8_t* data, size_t size) +void OnGetSupportedPowerModelFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GET_SUPPORTED_POWER_MODEL), datas); } -void OnGetPowerModelFuzzTest(const uint8_t* data, size_t size) +void OnGetPowerModelFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GET_POWER_MODEL), datas); } -void OnSetPowerModelFuzzTest(const uint8_t* data, size_t size) +void OnSetPowerModelFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_SET_POWER_MODEL), datas); } -void OnIsHotspotDualBandSupportedFuzzTest(const uint8_t* data, size_t size) +void OnIsHotspotDualBandSupportedFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_IS_HOTSPOT_DUAL_BAND_SUPPORTED), datas); } -void OnIsOpenSoftApAllowedFuzzTest(const uint8_t* data, size_t size) +void OnIsOpenSoftApAllowedFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_IS_HOTSPOT_SUPPORTED), datas); } -void OnSetApIdleTimeoutFuzzTest(const uint8_t* data, size_t size) +void OnSetApIdleTimeoutFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_SETTIMEOUT_AP), datas); } -void OnGetApIfaceNameFuzzTest(const uint8_t* data, size_t size) +void OnGetApIfaceNameFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_GET_IFACE_NAME), datas); } -void OnEnableWifiApTest(const uint8_t* data, size_t size) +void OnEnableWifiApTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_ENABLE_WIFI_AP), datas); } -void OnDisableWifiApTest(const uint8_t* data, size_t size) +void OnDisableWifiApTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(HotspotInterfaceCode::WIFI_SVR_CMD_DISABLE_WIFI_AP), datas); } -void OnEnableWifiFuzzTest(const uint8_t* data, size_t size) +void OnEnableWifiFuzzTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_WIFI), datas, reply, option); } -void OnDisableWifiFuzzTest(const uint8_t* data, size_t size) +void OnDisableWifiFuzzTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_DISABLE_WIFI), datas, reply, option); } -void OnGetSupportedFeaturesFuzzTest(const uint8_t* data, size_t size) +void OnGetSupportedFeaturesFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_SUPPORTED_FEATURES), datas); } -bool DoSomethingHotSpotMgrStubTest(const uint8_t* data, size_t size) +bool DoSomethingHotSpotMgrStubTest() { uint32_t code = static_cast(HotspotInterfaceCode::WIFI_MGR_GET_HOTSPOT_SERVICE); MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_HOSPOT_EX); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); datas.RewindRead(0); MessageParcel reply; MessageOption option; @@ -379,36 +431,47 @@ bool DoSomethingHotSpotMgrStubTest(const uint8_t* data, size_t size) return true; } -void WifiHotspotServiceImplFuzzTest(const uint8_t* data, size_t size) +void WifiHotspotServiceImplFuzzTest() { - WifiHotspotServiceImpl mWifiHotspotServiceImpl; - int index = 0; - KeyMgmt type = static_cast(static_cast(data[0]) % THREE); - BandType newBand = static_cast(static_cast(data[0]) % U32_AT_SIZE_ZERO); - int channelid = static_cast(data[0]); - std::string primaryDeviceType = std::string(reinterpret_cast(data), size); - std::string secondaryDeviceType = std::string(reinterpret_cast(data), size); + MessageParcel datas; + if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_HOSPOT_EX)) { + LOGE("WriteInterfaceToken failed!"); + return; + } + + int32_t randomInt = FDP->ConsumeIntegral(); + KeyMgmt type = static_cast(randomInt % THREE); + BandType newBand = static_cast(randomInt % U32_AT_SIZE_ZERO); + int32_t channelid = FDP->ConsumeIntegral(); + + std::string primaryDeviceType = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string secondaryDeviceType = FDP->ConsumeBytesAsString(NUM_BYTES); + std::vector bandsFromCenter; bandsFromCenter.push_back(newBand); + HotspotConfig config; StationInfo updateInfo; - if (size >= U32_AT_SIZE_ZERO) { - std::string deviceName = std::string(reinterpret_cast(data), size); - std::string networkName = std::string(reinterpret_cast(data), size); - std::string mDeviceAddress = std::string(reinterpret_cast(data), size); - config.SetSsid(deviceName); - config.SetPreSharedKey(networkName); - config.SetSecurityType(type); - config.SetBand(newBand); - config.SetBandWidth(channelid); - config.SetChannel(channelid); - config.SetMaxConn(channelid); - config.SetIpAddress(mDeviceAddress); - updateInfo.deviceName = deviceName; - updateInfo.bssid = networkName; - updateInfo.ipAddr = mDeviceAddress; - updateInfo.bssidType = static_cast(data[index++]); - } + + std::string deviceName = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string networkName = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string mDeviceAddress = FDP->ConsumeBytesAsString(NUM_BYTES); + + config.SetSsid(deviceName); + config.SetPreSharedKey(networkName); + config.SetSecurityType(type); + config.SetBand(newBand); + config.SetBandWidth(channelid); + config.SetChannel(channelid); + config.SetMaxConn(channelid); + config.SetIpAddress(mDeviceAddress); + + updateInfo.deviceName = deviceName; + updateInfo.bssid = networkName; + updateInfo.ipAddr = mDeviceAddress; + updateInfo.bssidType = FDP->ConsumeIntegral(); + + WifiHotspotServiceImpl mWifiHotspotServiceImpl; mWifiHotspotServiceImpl.SetHotspotConfig(config); mWifiHotspotServiceImpl.TransRandomToRealMac(updateInfo, updateInfo); mWifiHotspotServiceImpl.ConfigInfoDump(primaryDeviceType); @@ -421,36 +484,38 @@ void WifiHotspotServiceImplFuzzTest(const uint8_t* data, size_t size) mWifiHotspotServiceImpl.IsValidHotspotConfig(config, config, bandsFromCenter); } +void WifiDeviceFuzzTest() +{ + Init(); + OHOS::Wifi::OnIsHotspotActiveFuzzTest(); + OHOS::Wifi::OnGetApStateWifiFuzzTest(); + OHOS::Wifi::OnGetHotspotConfigFuzzTest(); + OHOS::Wifi::OnSetApConfigWifiFuzzTest(); + OHOS::Wifi::OnGetStationListFuzzTest(); + OHOS::Wifi::OnAddBlockListFuzzTest(); + OHOS::Wifi::OnDelBlockListFuzzTest(); + OHOS::Wifi::OnGetBlockListsFuzzTest(); + OHOS::Wifi::OnDisassociateStaFuzzTest(); + OHOS::Wifi::OnGetValidBandsFuzzTest(); + OHOS::Wifi::OnGetValidChannelsFuzzTest(); + OHOS::Wifi::OnRegisterCallBackFuzzTest(); + OHOS::Wifi::OnGetSupportedPowerModelFuzzTest(); + OHOS::Wifi::OnGetPowerModelFuzzTest(); + OHOS::Wifi::OnSetPowerModelFuzzTest(); + OHOS::Wifi::OnIsHotspotDualBandSupportedFuzzTest(); + OHOS::Wifi::OnIsOpenSoftApAllowedFuzzTest(); + OHOS::Wifi::OnSetApIdleTimeoutFuzzTest(); + OHOS::Wifi::OnGetApIfaceNameFuzzTest(); + OHOS::Wifi::OnGetSupportedFeaturesFuzzTest(); + OHOS::Wifi::WifiHotspotServiceImplFuzzTest(); + OHOS::Wifi::DoSomethingHotSpotMgrStubTest(); +} + /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= OHOS::Wifi::U32_AT_SIZE_ZERO)) { - return 0; - } - Init(); - OHOS::Wifi::OnIsHotspotActiveFuzzTest(data, size); - OHOS::Wifi::OnGetApStateWifiFuzzTest(data, size); - OHOS::Wifi::OnGetHotspotConfigFuzzTest(data, size); - OHOS::Wifi::OnSetApConfigWifiFuzzTest(data, size); - OHOS::Wifi::OnGetStationListFuzzTest(data, size); - OHOS::Wifi::OnAddBlockListFuzzTest(data, size); - OHOS::Wifi::OnDelBlockListFuzzTest(data, size); - OHOS::Wifi::OnGetBlockListsFuzzTest(data, size); - OHOS::Wifi::OnDisassociateStaFuzzTest(data, size); - OHOS::Wifi::OnGetValidBandsFuzzTest(data, size); - OHOS::Wifi::OnGetValidChannelsFuzzTest(data, size); - OHOS::Wifi::OnRegisterCallBackFuzzTest(data, size); - OHOS::Wifi::OnGetSupportedPowerModelFuzzTest(data, size); - OHOS::Wifi::OnGetPowerModelFuzzTest(data, size); - OHOS::Wifi::OnSetPowerModelFuzzTest(data, size); - OHOS::Wifi::OnIsHotspotDualBandSupportedFuzzTest(data, size); - OHOS::Wifi::OnIsOpenSoftApAllowedFuzzTest(data, size); - OHOS::Wifi::OnSetApIdleTimeoutFuzzTest(data, size); - OHOS::Wifi::OnGetApIfaceNameFuzzTest(data, size); - OHOS::Wifi::OnGetSupportedFeaturesFuzzTest(data, size); - OHOS::Wifi::WifiHotspotServiceImplFuzzTest(data, size); - OHOS::Wifi::DoSomethingHotSpotMgrStubTest(data, size); - sleep(4); + FuzzedDataProvider fdp(data, size); + OHOS::Wifi::FDP = &fdp; return 0; } } diff --git a/wifi/test/fuzztest/wifi_sta/wifip2pstub_fuzzer/wifip2pstub_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifip2pstub_fuzzer/wifip2pstub_fuzzer.cpp index 09c7848186daa3cb17fd080c9128cb34b567e831..1e2590307a29ba4a25580dd3a70d43777de8724e 100644 --- a/wifi/test/fuzztest/wifi_sta/wifip2pstub_fuzzer/wifip2pstub_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifip2pstub_fuzzer/wifip2pstub_fuzzer.cpp @@ -15,7 +15,7 @@ #include "wifip2pstub_fuzzer.h" #include "wifi_fuzz_common_func.h" - +#include #include #include #include @@ -36,8 +36,9 @@ namespace OHOS { namespace Wifi { +FuzzedDataProvider *FDP = nullptr; +const int32_t NUM_BYTES = 1; constexpr size_t U32_AT_SIZE_ZERO = 4; -constexpr int THREE = 4; const std::u16string FORMMGR_INTERFACE_TOKEN = u"ohos.wifi.IWifiP2pService"; const std::u16string FORMMGR_INTERFACE_TOKEN_DEVICE = u"ohos.wifi.IWifiDeviceService"; static bool g_isInsted = false; @@ -71,619 +72,723 @@ bool OnRemoteRequest(uint32_t code, MessageParcel &data) return true; } -void OnDiscoverDevicesFuzzTest(const uint8_t* data, size_t size) +void OnDiscoverDevicesFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_DISCOVER_DEVICES), datas); } -void OnStopDiscoverDevicesFuzzTest(const uint8_t* data, size_t size) +void OnStopDiscoverDevicesFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_STOP_DISCOVER_DEVICES), datas); } -void OnDiscoverServicesFuzzTest(const uint8_t* data, size_t size) +void OnDiscoverServicesFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_DISCOVER_SERVICES), datas); } -void OnStopDiscoverServicesFuzzTest(const uint8_t* data, size_t size) +void OnStopDiscoverServicesFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_STOP_DISCOVER_SERVICES), datas); } -void OnRequestServiceFuzzTest(const uint8_t* data, size_t size) +void OnRequestServiceFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_REQUEST_SERVICES), datas); } -void OnPutLocalP2pServiceFuzzTest(const uint8_t* data, size_t size) +void OnPutLocalP2pServiceFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_PUT_LOCAL_SERVICES), datas); } -void OnDeleteLocalP2pServiceFuzzTest(const uint8_t* data, size_t size) +void OnDeleteLocalP2pServiceFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_DELETE_LOCAL_SERVICES), datas); } -void OnStartP2pListenFuzzTest(const uint8_t* data, size_t size) +void OnStartP2pListenFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_START_LISTEN), datas); } -void OnStopP2pListenFuzzTest(const uint8_t* data, size_t size) +void OnStopP2pListenFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_STOP_LISTEN), datas); } -void OnCreateGroupFuzzTest(const uint8_t* data, size_t size) +void OnCreateGroupFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_CREATE_GROUP), datas); } -void OnRemoveGroupFuzzTest(const uint8_t* data, size_t size) +void OnRemoveGroupFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_REMOVE_GROUP), datas); } -void OnDeleteGroupFuzzTest(const uint8_t* data, size_t size) +void OnRemoveGroupClientFuzzTest() +{ + MessageParcel datas; + if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { + LOGE("WriteInterfaceToken failed!"); + return; + } + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); + OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_REMOVE_GROUP_CLIENT), datas); +} + +void OnDeleteGroupFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_DELETE_GROUP), datas); } -void OnP2pConnectFuzzTest(const uint8_t* data, size_t size) +void OnP2pConnectFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_CONNECT), datas); } -void OnP2pCancelConnectFuzzTest(const uint8_t* data, size_t size) +void OnP2pCancelConnectFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_CANCEL_CONNECT), datas); } -void OnQueryP2pLinkedInfoFuzzTest(const uint8_t* data, size_t size) +void OnQueryP2pLinkedInfoFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_QUERY_INFO), datas); } -void OnGetCurrentGroupFuzzTest(const uint8_t* data, size_t size) +void OnGetCurrentGroupFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_GET_CURRENT_GROUP), datas); } -void OnGetP2pEnableStatusFuzzTest(const uint8_t* data, size_t size) +void OnGetP2pEnableStatusFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_GET_ENABLE_STATUS), datas); } -void OnGetP2pDiscoverStatusFuzzTest(const uint8_t* data, size_t size) +void OnGetP2pDiscoverStatusFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_GET_DISCOVER_STATUS), datas); } -void OnGetP2pConnectedStatusFuzzTest(const uint8_t* data, size_t size) +void OnGetP2pConnectedStatusFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_GET_CONNECTED_STATUS), datas); } -void OnQueryP2pDevicesFuzzTest(const uint8_t* data, size_t size) +void OnQueryP2pDevicesFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_QUERY_DEVICES), datas); } -void OnQueryP2pGroupsFuzzTest(const uint8_t* data, size_t size) +void OnQueryP2pGroupsFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_QUERY_GROUPS), datas); } -void OnQueryP2pServicesFuzzTest(const uint8_t* data, size_t size) +void OnQueryP2pServicesFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_QUERY_SERVICES), datas); } -void OnRegisterCallBackFuzzTest(const uint8_t* data, size_t size) +void OnRegisterCallBackFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_REGISTER_CALLBACK), datas); } -void OnSetP2pDeviceNameFuzzTest(const uint8_t* data, size_t size) +void OnSetP2pDeviceNameFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_SET_DEVICE_NAME), datas); } -void OnSetP2pWfdInfoFuzzTest(const uint8_t* data, size_t size) +void OnSetP2pWfdInfoFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_SET_WFD_INFO), datas); } -void OnHid2dRequestGcIpFuzzTest(const uint8_t* data, size_t size) +void OnHid2dRequestGcIpFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_APPLY_IP), datas); } -void OnHid2dSharedlinkIncreaseFuzzTest(const uint8_t* data, size_t size) +void OnHid2dSharedlinkIncreaseFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_SHARED_LINK_INCREASE), datas); } -void OnHid2dSharedlinkDecreaseFuzzTest(const uint8_t* data, size_t size) +void OnHid2dSharedlinkDecreaseFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_SHARED_LINK_DECREASE), datas); } -void OnHid2dCreateGroupFuzzTest(const uint8_t* data, size_t size) +void OnHid2dCreateGroupFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_CREATE_GROUP), datas); } -void OnHid2dRemoveGcGroupFuzzTest(const uint8_t* data, size_t size) +void OnHid2dRemoveGcGroupFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_REMOVE_GC_GROUP), datas); } -void OnHid2dConnectFuzzTest(const uint8_t* data, size_t size) +void OnHid2dConnectFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_CONNECT), datas); } -void OnHid2dConfigIPAddrFuzzTest(const uint8_t* data, size_t size) +void OnHid2dConfigIPAddrFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_CONFIG_IP), datas); } -void OnHid2dReleaseIPAddrFuzzTest(const uint8_t* data, size_t size) +void OnHid2dReleaseIPAddrFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_RELEASE_IP), datas); } -void OnHid2dGetRecommendChannelFuzzTest(const uint8_t* data, size_t size) +void OnHid2dGetRecommendChannelFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_GET_P2P_RECOMMENDED_CHANNEL), datas); } -void OnHid2dGetChannelListFor5GFuzzTest(const uint8_t* data, size_t size) +void OnHid2dGetChannelListFor5GFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_GET_5G_CHANNEL_LIST), datas); } -void OnHid2dGetSelfWifiCfgInfoFuzzTest(const uint8_t* data, size_t size) +void OnHid2dGetSelfWifiCfgInfoFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_GET_SELF_WIFI_CFG), datas); } -void OnHid2dSetPeerWifiCfgInfoFuzzTest(const uint8_t* data, size_t size) +void OnHid2dSetPeerWifiCfgInfoFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_SET_PEER_WIFI_CFG), datas); } -void OnQueryP2pLocalDeviceFuzzTest(const uint8_t* data, size_t size) +void OnQueryP2pLocalDeviceFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_QUERY_LOCAL_DEVICE), datas); } -void OnHid2dSetUpperSceneFuzzTest(const uint8_t* data, size_t size) +void OnHid2dSetUpperSceneFuzzTest() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_SET_UPPER_SCENE), datas); } -void DoSomethingInterestingWithMyAPIS(const uint8_t* data, size_t size) +void DoSomethingInterestingWithMyAPIS() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_ENABLE), datas); } -void DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +void DoSomethingInterestingWithMyAPI() { MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_DISABLE), datas); } -void OnEnableWifiFuzzTest(const uint8_t* data, size_t size) +void OnEnableWifiFuzzTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_ENABLE_WIFI), datas, reply, option); } -void OnDisableWifiFuzzTest(const uint8_t* data, size_t size) +void OnDisableWifiFuzzTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_DISABLE_WIFI), datas, reply, option); } -void OnDiscoverPeersFuzzTest(const uint8_t* data, size_t size) +void OnDiscoverPeersFuzzTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_DISCOVER_PEERS), datas, reply, option); } -void OnDisableRandomMacFuzzTest(const uint8_t* data, size_t size) +void OnDisableRandomMacFuzzTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_DISABLE_RANDOM_MAC), datas, reply, option); } -void OnCheckCanUseP2pFuzzTest(const uint8_t* data, size_t size) +void OnCheckCanUseP2pFuzzTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_CHECK_CAN_USE_P2P), datas, reply, option); } -void Hid2dIsWideBandwidthSupportedFuzzTest(const uint8_t* data, size_t size) +void Hid2dIsWideBandwidthSupportedFuzzTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN_DEVICE); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest(static_cast(P2PInterfaceCode::WIFI_SVR_CMD_P2P_HID2D_WIDE_SUPPORTED), datas, reply, option); } -void WifiP2pServiceImplFuzzTest(const uint8_t* data, size_t size) +void WifiP2pServiceImplFuzzTest() { WifiP2pServiceInfo srvInfo; - std::string serviceName = std::string(reinterpret_cast(data), size); - std::string mDeviceAddress = std::string(reinterpret_cast(data), size); + std::string serviceName = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string mDeviceAddress = FDP->ConsumeBytesAsString(NUM_BYTES); srvInfo.SetServiceName(serviceName); srvInfo.SetDeviceAddress(mDeviceAddress); WifiP2pDevice device; - if (size >= THREE) { - int index = 0; - std::string deviceName = std::string(reinterpret_cast(data), size); - std::string networkName = std::string(reinterpret_cast(data), size); - std::string mDeviceAddress = std::string(reinterpret_cast(data), size); - std::string primaryDeviceType = std::string(reinterpret_cast(data), size); - std::string secondaryDeviceType = std::string(reinterpret_cast(data), size); - unsigned int supportWpsConfigMethods = static_cast(data[index++]); - int deviceCapabilitys = static_cast(data[index++]); - int groupCapabilitys = static_cast(data[index++]); - device.SetDeviceName(deviceName); - device.SetNetworkName(networkName); - device.SetDeviceAddress(mDeviceAddress); - device.SetPrimaryDeviceType(primaryDeviceType); - device.SetSecondaryDeviceType(secondaryDeviceType); - device.SetWpsConfigMethod(supportWpsConfigMethods); - device.SetDeviceCapabilitys(deviceCapabilitys); - device.SetGroupCapabilitys(groupCapabilitys); - } + std::string deviceName = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string networkName = FDP->ConsumeBytesAsString(NUM_BYTES); + mDeviceAddress = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string primaryDeviceType = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string secondaryDeviceType = FDP->ConsumeBytesAsString(NUM_BYTES); + unsigned int supportWpsConfigMethods = FDP->ConsumeIntegral(); + int deviceCapabilitys = FDP->ConsumeIntegral(); + int groupCapabilitys = FDP->ConsumeIntegral(); + device.SetDeviceName(deviceName); + device.SetNetworkName(networkName); + device.SetDeviceAddress(mDeviceAddress); + device.SetPrimaryDeviceType(primaryDeviceType); + device.SetSecondaryDeviceType(secondaryDeviceType); + device.SetWpsConfigMethod(supportWpsConfigMethods); + device.SetDeviceCapabilitys(deviceCapabilitys); + device.SetGroupCapabilitys(groupCapabilitys); WifiP2pGroupInfo group; - if (size >= THREE) { - std::string passphrase = std::string(reinterpret_cast(data), size); - std::string interface = std::string(reinterpret_cast(data), size); - std::string groupName = std::string(reinterpret_cast(data), size); - int frequency = static_cast(data[0]); - - group.SetPassphrase(passphrase); - group.SetInterface(interface); - group.SetGroupName(groupName); - group.SetFrequency(frequency); - } + std::string passphrase = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string interface = FDP->ConsumeBytesAsString(NUM_BYTES); + std::string groupName = FDP->ConsumeBytesAsString(NUM_BYTES); + int frequency = FDP->ConsumeIntegral(); + group.SetPassphrase(passphrase); + group.SetInterface(interface); + group.SetGroupName(groupName); + group.SetFrequency(frequency); MessageParcel datas; if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { LOGE("WriteInterfaceToken failed!"); return; } - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_SUPPORTED_FEATURES), datas); pWifiP2pServiceImpl->WriteWifiP2pServiceInfo(datas, srvInfo); pWifiP2pServiceImpl->WriteWifiP2pDeviceData(datas, device); @@ -691,12 +796,14 @@ void WifiP2pServiceImplFuzzTest(const uint8_t* data, size_t size) pWifiP2pServiceImpl->WriteWifiP2pServiceInfo(datas, srvInfo); } -void OnGetSupportChanForBandTest(const uint8_t* data, size_t size) +void OnGetSupportChanForBandTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest( @@ -704,12 +811,14 @@ void OnGetSupportChanForBandTest(const uint8_t* data, size_t size) datas, reply, option); } -void OnSetP2pHighPerfTest(const uint8_t* data, size_t size) +void OnSetP2pHighPerfTest() { MessageParcel datas; datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN); - datas.WriteInt32(0); - datas.WriteBuffer(data, size); + int32_t tmpInt = FDP->ConsumeIntegral(); + std::string tmpBuffer = FDP->ConsumeBytesAsString(NUM_BYTES); + datas.WriteInt32(tmpInt); + datas.WriteBuffer(tmpBuffer.c_str(), tmpBuffer.size()); MessageParcel reply; MessageOption option; pWifiDeviceStub->OnRemoteRequest( @@ -717,6 +826,56 @@ void OnSetP2pHighPerfTest(const uint8_t* data, size_t size) datas, reply, option); } +void WifiP2pStubFuzzTest() +{ + OHOS::Wifi::OnDiscoverDevicesFuzzTest(); + OHOS::Wifi::OnDiscoverPeersFuzzTest(); + OHOS::Wifi::OnDisableRandomMacFuzzTest(); + OHOS::Wifi::OnCheckCanUseP2pFuzzTest(); + OHOS::Wifi::OnStopDiscoverDevicesFuzzTest(); + OHOS::Wifi::OnDiscoverServicesFuzzTest(); + OHOS::Wifi::OnStopDiscoverServicesFuzzTest(); + OHOS::Wifi::OnRequestServiceFuzzTest(); + OHOS::Wifi::OnPutLocalP2pServiceFuzzTest(); + OHOS::Wifi::OnDeleteLocalP2pServiceFuzzTest(); + OHOS::Wifi::OnStartP2pListenFuzzTest(); + OHOS::Wifi::OnStopP2pListenFuzzTest(); + OHOS::Wifi::OnCreateGroupFuzzTest(); + OHOS::Wifi::OnRemoveGroupFuzzTest(); + OHOS::Wifi::OnDeleteGroupFuzzTest(); + OHOS::Wifi::OnP2pConnectFuzzTest(); + OHOS::Wifi::OnP2pCancelConnectFuzzTest(); + OHOS::Wifi::OnQueryP2pLinkedInfoFuzzTest(); + OHOS::Wifi::OnGetCurrentGroupFuzzTest(); + OHOS::Wifi::OnGetP2pEnableStatusFuzzTest(); + OHOS::Wifi::OnGetP2pDiscoverStatusFuzzTest(); + OHOS::Wifi::OnGetP2pConnectedStatusFuzzTest(); + OHOS::Wifi::OnQueryP2pDevicesFuzzTest(); + OHOS::Wifi::OnQueryP2pGroupsFuzzTest(); + OHOS::Wifi::OnQueryP2pServicesFuzzTest(); + OHOS::Wifi::OnRegisterCallBackFuzzTest(); + OHOS::Wifi::OnSetP2pDeviceNameFuzzTest(); + OHOS::Wifi::OnSetP2pWfdInfoFuzzTest(); + OHOS::Wifi::OnHid2dRequestGcIpFuzzTest(); + OHOS::Wifi::OnHid2dSharedlinkIncreaseFuzzTest(); + OHOS::Wifi::OnHid2dSharedlinkDecreaseFuzzTest(); + OHOS::Wifi::OnHid2dCreateGroupFuzzTest(); + OHOS::Wifi::OnHid2dRemoveGcGroupFuzzTest(); + OHOS::Wifi::OnHid2dConnectFuzzTest(); + OHOS::Wifi::OnHid2dConfigIPAddrFuzzTest(); + OHOS::Wifi::OnHid2dReleaseIPAddrFuzzTest(); + OHOS::Wifi::OnHid2dGetRecommendChannelFuzzTest(); + OHOS::Wifi::OnHid2dGetChannelListFor5GFuzzTest(); + OHOS::Wifi::OnHid2dGetSelfWifiCfgInfoFuzzTest(); + OHOS::Wifi::OnHid2dSetPeerWifiCfgInfoFuzzTest(); + OHOS::Wifi::OnQueryP2pLocalDeviceFuzzTest(); + OHOS::Wifi::OnHid2dSetUpperSceneFuzzTest(); + OHOS::Wifi::DoSomethingInterestingWithMyAPI(); + OHOS::Wifi::WifiP2pServiceImplFuzzTest(); + OHOS::Wifi::Hid2dIsWideBandwidthSupportedFuzzTest(); + OHOS::Wifi::OnRemoveGroupClientFuzzTest(); +} + /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { @@ -724,51 +883,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) return 0; } Init(); - OHOS::Wifi::OnDiscoverDevicesFuzzTest(data, size); - OHOS::Wifi::OnDiscoverPeersFuzzTest(data, size); - OHOS::Wifi::OnDisableRandomMacFuzzTest(data, size); - OHOS::Wifi::OnCheckCanUseP2pFuzzTest(data, size); - OHOS::Wifi::OnStopDiscoverDevicesFuzzTest(data, size); - OHOS::Wifi::OnDiscoverServicesFuzzTest(data, size); - OHOS::Wifi::OnStopDiscoverServicesFuzzTest(data, size); - OHOS::Wifi::OnRequestServiceFuzzTest(data, size); - OHOS::Wifi::OnPutLocalP2pServiceFuzzTest(data, size); - OHOS::Wifi::OnDeleteLocalP2pServiceFuzzTest(data, size); - OHOS::Wifi::OnStartP2pListenFuzzTest(data, size); - OHOS::Wifi::OnStopP2pListenFuzzTest(data, size); - OHOS::Wifi::OnCreateGroupFuzzTest(data, size); - OHOS::Wifi::OnRemoveGroupFuzzTest(data, size); - OHOS::Wifi::OnDeleteGroupFuzzTest(data, size); - OHOS::Wifi::OnP2pConnectFuzzTest(data, size); - OHOS::Wifi::OnP2pCancelConnectFuzzTest(data, size); - OHOS::Wifi::OnQueryP2pLinkedInfoFuzzTest(data, size); - OHOS::Wifi::OnGetCurrentGroupFuzzTest(data, size); - OHOS::Wifi::OnGetP2pEnableStatusFuzzTest(data, size); - OHOS::Wifi::OnGetP2pDiscoverStatusFuzzTest(data, size); - OHOS::Wifi::OnGetP2pConnectedStatusFuzzTest(data, size); - OHOS::Wifi::OnQueryP2pDevicesFuzzTest(data, size); - OHOS::Wifi::OnQueryP2pGroupsFuzzTest(data, size); - OHOS::Wifi::OnQueryP2pServicesFuzzTest(data, size); - OHOS::Wifi::OnRegisterCallBackFuzzTest(data, size); - OHOS::Wifi::OnSetP2pDeviceNameFuzzTest(data, size); - OHOS::Wifi::OnSetP2pWfdInfoFuzzTest(data, size); - OHOS::Wifi::OnHid2dRequestGcIpFuzzTest(data, size); - OHOS::Wifi::OnHid2dSharedlinkIncreaseFuzzTest(data, size); - OHOS::Wifi::OnHid2dSharedlinkDecreaseFuzzTest(data, size); - OHOS::Wifi::OnHid2dCreateGroupFuzzTest(data, size); - OHOS::Wifi::OnHid2dRemoveGcGroupFuzzTest(data, size); - OHOS::Wifi::OnHid2dConnectFuzzTest(data, size); - OHOS::Wifi::OnHid2dConfigIPAddrFuzzTest(data, size); - OHOS::Wifi::OnHid2dReleaseIPAddrFuzzTest(data, size); - OHOS::Wifi::OnHid2dGetRecommendChannelFuzzTest(data, size); - OHOS::Wifi::OnHid2dGetChannelListFor5GFuzzTest(data, size); - OHOS::Wifi::OnHid2dGetSelfWifiCfgInfoFuzzTest(data, size); - OHOS::Wifi::OnHid2dSetPeerWifiCfgInfoFuzzTest(data, size); - OHOS::Wifi::OnQueryP2pLocalDeviceFuzzTest(data, size); - OHOS::Wifi::OnHid2dSetUpperSceneFuzzTest(data, size); - OHOS::Wifi::DoSomethingInterestingWithMyAPI(data, size); - OHOS::Wifi::WifiP2pServiceImplFuzzTest(data, size); - OHOS::Wifi::Hid2dIsWideBandwidthSupportedFuzzTest(data, size); + FuzzedDataProvider fdp(data, size); + OHOS::Wifi::FDP = &fdp; + OHOS::Wifi::WifiP2pStubFuzzTest(); sleep(U32_AT_SIZE_ZERO); return 0; }