1 /*
2 * Copyright (C) 2022-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 "datatransmitmgr_fuzzer.h"
17
18 #include <cstddef>
19 #include <cstdint>
20
21 #include "securec.h"
22 #include "dev_slinfo_mgr.h"
23
24 namespace OHOS {
tmpCallback(DEVSLQueryParams * queryParams,int32_t result,uint32_t levelInfo)25 static void tmpCallback(DEVSLQueryParams *queryParams, int32_t result, uint32_t levelInfo)
26 {
27 return;
28 }
29
FuzzDoDataTransmitMgr(const uint8_t * data,size_t size)30 void FuzzDoDataTransmitMgr(const uint8_t *data, size_t size)
31 {
32 if (data == nullptr || size <= MAX_UDID_LENGTH) {
33 return;
34 }
35
36 uint32_t levelInfo = 0;
37 DEVSLQueryParams queryParams;
38 (void)memset_s(&queryParams, sizeof(DEVSLQueryParams), 0, sizeof(DEVSLQueryParams));
39 queryParams.udidLen = size;
40 (void)memcpy_s(queryParams.udid, MAX_UDID_LENGTH, data, MAX_UDID_LENGTH);
41
42 (void)DATASL_OnStart();
43 (void)DATASL_GetHighestSecLevelAsync(&queryParams, tmpCallback);
44 (void)DATASL_GetHighestSecLevel(&queryParams, &levelInfo);
45 DATASL_OnStop();
46 }
47 }
48
49 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)50 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
51 {
52 /* Run your code on data */
53 OHOS::FuzzDoDataTransmitMgr(data, size);
54 return 0;
55 }