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