• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "arkuiformrendergroup_fuzzer.h"
17 
18 #define private public
19 #define protected public
20 #include "form_render/include/form_renderer_delegate_proxy.h"
21 #include "form_render/include/form_renderer_dispatcher_proxy.h"
22 #include "form_render/include/form_renderer_group.h"
23 #undef private
24 #undef protected
25 
26 namespace OHOS::Ace {
27 const uint32_t u16m = 65535;
FormRenderGroup(const std::string data,size_t size)28 bool FormRenderGroup(const std::string data, size_t size)
29 {
30     std::shared_ptr<OHOS::AbilityRuntime::Context> context;
31     std::shared_ptr<OHOS::AbilityRuntime::Runtime> runtime;
32     auto fromGroup = FormRendererGroup::Create(context, runtime);
33     AAFwk::Want want;
34     OHOS::AppExecFwk::FormJsInfo formJsInfo;
35     fromGroup->AddForm(want, formJsInfo);
36     fromGroup->ReloadForm();
37     auto id = size % u16m;
38     fromGroup->DeleteForm(std::to_string(id));
39     return true;
40 }
41 }
42 
43 using namespace OHOS;
44 using namespace OHOS::Ace;
45 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)46 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
47 {
48     auto ri = size % u16m;
49     std::string str(reinterpret_cast<const char*>(data), ri);
50     /* Run your code on data */
51     FormRenderGroup(str, size);
52     return 0;
53 }
54