100600bfbSopenharmony_ci/*
200600bfbSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
300600bfbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
400600bfbSopenharmony_ci * you may not use this file except in compliance with the License.
500600bfbSopenharmony_ci * You may obtain a copy of the License at
600600bfbSopenharmony_ci *
700600bfbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
800600bfbSopenharmony_ci *
900600bfbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1000600bfbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1100600bfbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1200600bfbSopenharmony_ci * See the License for the specific language governing permissions and
1300600bfbSopenharmony_ci * limitations under the License.
1400600bfbSopenharmony_ci */
1500600bfbSopenharmony_ci
1600600bfbSopenharmony_ci#include <cstddef>
1700600bfbSopenharmony_ci#include <cstdint>
1800600bfbSopenharmony_ci#include <string>
1900600bfbSopenharmony_ci#include <unistd.h>
2000600bfbSopenharmony_ci#include "string_ex.h"
2100600bfbSopenharmony_ci#include "dump_manager_client.h"
2200600bfbSopenharmony_ci
2300600bfbSopenharmony_cinamespace OHOS {
2400600bfbSopenharmony_ci    bool ClientFuzzTest(const uint8_t* data, size_t size)
2500600bfbSopenharmony_ci    {
2600600bfbSopenharmony_ci        std::string randomData(reinterpret_cast<const char*>(data), size);
2700600bfbSopenharmony_ci        auto& dumpManagerClient = HiviewDFX::DumpManagerClient::GetInstance();
2800600bfbSopenharmony_ci        std::vector<std::u16string> args{
2900600bfbSopenharmony_ci            std::u16string(u"hidumper"),
3000600bfbSopenharmony_ci            Str8ToStr16(randomData)
3100600bfbSopenharmony_ci        };
3200600bfbSopenharmony_ci        dumpManagerClient.Request(args, STDOUT_FILENO);
3300600bfbSopenharmony_ci        return true;
3400600bfbSopenharmony_ci    }
3500600bfbSopenharmony_ci}
3600600bfbSopenharmony_ci
3700600bfbSopenharmony_ci/* Fuzzer entry point */
3800600bfbSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
3900600bfbSopenharmony_ci{
4000600bfbSopenharmony_ci    /* Run your code on data */
4100600bfbSopenharmony_ci    OHOS::ClientFuzzTest(data, size);
4200600bfbSopenharmony_ci    return 0;
4300600bfbSopenharmony_ci}
4400600bfbSopenharmony_ci
45