1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * SPDX-License-Identifier: GPL-2.0
4 *
5 * Unless required by applicable law or agreed to in writing, software
6 * distributed under the License is distributed on an "AS IS" BASIS,
7 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8 * See the License for the specific language governing permissions and
9 * limitations under the License.
10 */
11
12 #include <vector>
13 #include <cstddef>
14 #include <cstdint>
15 #include "__config"
16 #include "rtg_interface.h"
17
18 using namespace std;
19 using namespace OHOS::RME;
20 namespace OHOS {
SetMarginFuzzTest(const uint8_t * data,size_t size)21 bool SetMarginFuzzTest(const uint8_t *data, size_t size)
22 {
23 bool ret = false;
24 constexpr int marginUpperLimitTime = 32000;
25 constexpr int marginLowerLimitTime = -32000;
26 if (data == nullptr) {
27 return ret;
28 } else {
29 uint8_t *countData = const_cast<uint8_t *>(data);
30 int margin = *(reinterpret_cast<int *>(countData));
31 if (margin < marginLowerLimitTime || margin > marginUpperLimitTime) {
32 return ret;
33 }
34 int grpId = 2;
35 ret = SetMargin(grpId, margin);
36 }
37 return ret;
38 }
39 }
40
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)41 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
42 {
43 OHOS::SetMarginFuzzTest(data, size);
44 return 0;
45 }
46