• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "clienttranspending_fuzzer.h"
17 #include <cstddef>
18 #include <cstdint>
19 #include <cinttypes>
20 #include <string>
21 #include "client_trans_pending.h"
22 #include "common_list.h"
23 #include "fuzz_data_generator.h"
24 #include "securec.h"
25 #include "softbus_adapter_mem.h"
26 #include "softbus_def.h"
27 #include "softbus_error_code.h"
28 #include "softbus_type_def.h"
29 
30 namespace OHOS {
ClientTransPendingTest(const uint8_t * data,size_t size)31 void ClientTransPendingTest(const uint8_t* data, size_t size)
32 {
33     if ((data == nullptr) || (size < sizeof(uint64_t))) {
34         return;
35     }
36     DataGenerator::Write(data, size);
37 
38     uint32_t id = 0;
39     uint64_t seq = 0;
40     uint32_t waitMillis = 0;
41     bool isDelete = 0;
42     TransPendData pendDate = {0};
43     GenerateUint32(id);
44     GenerateUint64(seq);
45     GenerateUint32(waitMillis);
46     GenerateBool(isDelete);
47 
48     CreatePendingPacket(id, seq);
49     DeletePendingPacket(id, seq);
50     GetPendingPacketData(id, seq, waitMillis, isDelete, &pendDate);
51     SetPendingPacketData(id, seq, &pendDate);
52     DataGenerator::Clear();
53 }
54 } // namespace OHOS
55 
56 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)57 extern "C" int32_t LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
58 {
59     /* Run your code on data */
60     OHOS::ClientTransPendingTest(data, size);
61     return 0;
62 }
63