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 "clienttransproxyfilemanager_fuzzer.h"
17
18 #include <cstddef>
19 #include <cstdint>
20 #include <cinttypes>
21 #include <limits>
22 #include <string>
23 #include <unistd.h>
24
25 #include "client_trans_proxy_file_manager.h"
26 #include "client_trans_pending.h"
27 #include "client_trans_proxy_file_common.h"
28 #include "client_trans_session_manager.h"
29 #include "client_trans_socket_manager.h"
30 #include "client_trans_tcp_direct_message.h"
31 #include "securec.h"
32 #include "softbus_adapter_errcode.h"
33 #include "softbus_adapter_file.h"
34 #include "softbus_adapter_mem.h"
35 #include "softbus_adapter_timer.h"
36 #include "softbus_app_info.h"
37 #include "softbus_conn_interface.h"
38 #include "softbus_def.h"
39 #include "softbus_errcode.h"
40 #include "softbus_type_def.h"
41 #include "softbus_utils.h"
42 #include "trans_server_proxy.h"
43
44 namespace OHOS {
ClientTransProxyFileManagerTest(const uint8_t * data,size_t size)45 void ClientTransProxyFileManagerTest(const uint8_t* data, size_t size)
46 {
47 if ((data == nullptr) || (size < sizeof(int32_t))) {
48 return;
49 }
50
51 int32_t channelId = *(reinterpret_cast<const int32_t*>(data));
52 const char **sFileList = nullptr;
53 const char **dFileList = nullptr;
54 uint32_t fileCnt = *(reinterpret_cast<const uint32_t*>(data));
55 int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
56 const FileFrame oneFrame = {0};
57
58 ProxyChannelSendFile(channelId, sFileList, dFileList, fileCnt);
59
60 ProcessRecvFileFrameData(sessionId, channelId, &oneFrame);
61 }
62 } // namespace OHOS
63
64 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)65 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
66 {
67 /* Run your code on data */
68 OHOS::ClientTransProxyFileManagerTest(data, size);
69 return 0;
70 }
71