• 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 "clienttransstream_fuzzer.h"
17 #include <cstddef>
18 #include <cstdint>
19 #include "client_trans_stream.h"
20 #include "session.h"
21 #include "softbus_def.h"
22 
23 namespace OHOS {
TransOnstreamChannelOpenedTest(const uint8_t * data,size_t size)24     void TransOnstreamChannelOpenedTest(const uint8_t* data, size_t size)
25     {
26         if ((data == nullptr) || (size == 0)) {
27             return;
28         }
29         ChannelInfo *channel = nullptr;
30 
31         TransOnstreamChannelOpened(channel, (int32_t *)size);
32     }
33 
TransSendStreamTest(const uint8_t * data,size_t size)34     void TransSendStreamTest(const uint8_t* data, size_t size)
35     {
36         if ((data == nullptr) || (size == 0)) {
37             return;
38         }
39         StreamData *streamdata = nullptr;
40         StreamData *ext = nullptr;
41         StreamFrameInfo *param = nullptr;
42 
43         TransSendStream(size, streamdata, ext, param);
44     }
45 
TransCloseStreamChannelTest(const uint8_t * data,size_t size)46     void TransCloseStreamChannelTest(const uint8_t* data, size_t size)
47     {
48         if ((data == nullptr) || (size == 0)) {
49             return;
50         }
51 
52         TransCloseStreamChannel(size);
53     }
54 } // namespace OHOS
55 
56 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)57 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
58 {
59     /* Run your code on data */
60     OHOS::TransOnstreamChannelOpenedTest(data, size);
61     OHOS::TransSendStreamTest(data, size);
62     OHOS::TransCloseStreamChannelTest(data, size);
63 
64     return 0;
65 }
66 
67