SetParameterCpp_fuzzer.cpp 1.1 KB
Newer Older
X
xionglei6 已提交
1
/*
C
chengjinsong2 已提交
2
 * Copyright (c) 2022 Huawei Device Co., Ltd.
X
xionglei6 已提交
3 4 5 6
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
C
chengjinsong2 已提交
7
 * http://www.apache.org/licenses/LICENSE-2.0
X
xionglei6 已提交
8 9 10 11 12 13 14 15
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

C
chengjinsong2 已提交
16 17 18
#include "SetParameterCpp_fuzzer.h"
#include<string>
#include "parameters.h"
X
xionglei6 已提交
19 20

namespace OHOS {
C
chengjinsong2 已提交
21
    bool FuzzSetParameter(const uint8_t* data, size_t size)
X
xionglei6 已提交
22 23
    {
        bool result = false;
C
chengjinsong2 已提交
24 25
        std::string key(reinterpret_cast<const char*>(data), size);
        if (system::SetParameter(key, key)) {
X
xionglei6 已提交
26 27 28 29 30 31 32 33 34 35
            result = true;
        }
        return result;
    }
}

/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
    /* Run your code on data */
C
chengjinsong2 已提交
36
    OHOS::FuzzSetParameter(data, size);
X
xionglei6 已提交
37 38
    return 0;
}