1 /*
2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "pin_auth_ui.h"
17
18 #include "dm_ability_manager.h"
19 #include "dm_constants.h"
20 #include "dm_log.h"
21 #include "nlohmann/json.hpp"
22 #include "parameter.h"
23 #include "device_manager_service_listener.h"
24
25 #include "pinauthui_fuzzer.h"
26
27 namespace OHOS {
28 namespace DistributedHardware {
PinAuthUiFuzzTest(const uint8_t * data,size_t size)29 void PinAuthUiFuzzTest(const uint8_t* data, size_t size)
30 {
31 if ((data == nullptr) || (size < sizeof(int32_t))) {
32 return;
33 }
34
35 int32_t pageId = *(reinterpret_cast<const int32_t*>(data));
36 std::shared_ptr<DmAuthManager> authManager = nullptr;
37 std::shared_ptr<PinAuthUi> pinauthui = std::make_shared<PinAuthUi>();
38 pinauthui->ShowPinDialog(pageId, authManager);
39 pinauthui->InputPinDialog(authManager);
40 }
41 }
42 }
43
44 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)45 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
46 {
47 /* Run your code on data */
48 OHOS::DistributedHardware::PinAuthUiFuzzTest(data, size);
49
50 return 0;
51 }
52