1cb7eb8c9Sopenharmony_ci/* 2cb7eb8c9Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3cb7eb8c9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4cb7eb8c9Sopenharmony_ci * you may not use this file except in compliance with the License. 5cb7eb8c9Sopenharmony_ci * You may obtain a copy of the License at 6cb7eb8c9Sopenharmony_ci * 7cb7eb8c9Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8cb7eb8c9Sopenharmony_ci * 9cb7eb8c9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10cb7eb8c9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11cb7eb8c9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12cb7eb8c9Sopenharmony_ci * See the License for the specific language governing permissions and 13cb7eb8c9Sopenharmony_ci * limitations under the License. 14cb7eb8c9Sopenharmony_ci */ 15cb7eb8c9Sopenharmony_ci#include "daemonstub_fuzzer.h" 16cb7eb8c9Sopenharmony_ci 17cb7eb8c9Sopenharmony_ci#include <cstddef> 18cb7eb8c9Sopenharmony_ci#include <cstdint> 19cb7eb8c9Sopenharmony_ci#include <cstring> 20cb7eb8c9Sopenharmony_ci#include <string> 21cb7eb8c9Sopenharmony_ci 22cb7eb8c9Sopenharmony_ci#include "daemon_stub.h" 23cb7eb8c9Sopenharmony_ci#include "distributed_file_daemon_ipc_interface_code.h" 24cb7eb8c9Sopenharmony_ci#include "ipc_skeleton.h" 25cb7eb8c9Sopenharmony_ci#include "message_option.h" 26cb7eb8c9Sopenharmony_ci#include "message_parcel.h" 27cb7eb8c9Sopenharmony_ci#include "securec.h" 28cb7eb8c9Sopenharmony_ci#include "accesstoken_kit.h" 29cb7eb8c9Sopenharmony_ci#include "utils_log.h" 30cb7eb8c9Sopenharmony_ci#include "nativetoken_kit.h" 31cb7eb8c9Sopenharmony_ci#include "token_setproc.h" 32cb7eb8c9Sopenharmony_ci 33cb7eb8c9Sopenharmony_cinamespace OHOS { 34cb7eb8c9Sopenharmony_ciconstexpr pid_t DATA_UID = 3012; 35cb7eb8c9Sopenharmony_ciconstexpr pid_t DAEMON_UID = 1009; 36cb7eb8c9Sopenharmony_cistatic pid_t UID = DAEMON_UID; 37cb7eb8c9Sopenharmony_ci#ifdef CONFIG_IPC_SINGLE 38cb7eb8c9Sopenharmony_ciusing namespace IPC_SINGLE; 39cb7eb8c9Sopenharmony_ci#endif 40cb7eb8c9Sopenharmony_cipid_t IPCSkeleton::GetCallingUid() 41cb7eb8c9Sopenharmony_ci{ 42cb7eb8c9Sopenharmony_ci return UID; 43cb7eb8c9Sopenharmony_ci} 44cb7eb8c9Sopenharmony_ci} 45cb7eb8c9Sopenharmony_ci 46cb7eb8c9Sopenharmony_cinamespace OHOS { 47cb7eb8c9Sopenharmony_ci 48cb7eb8c9Sopenharmony_ciconstexpr size_t FOO_MAX_LEN = 1024; 49cb7eb8c9Sopenharmony_ciconstexpr size_t U32_AT_SIZE = 4; 50cb7eb8c9Sopenharmony_ci 51cb7eb8c9Sopenharmony_ciusing namespace OHOS::Storage::DistributedFile; 52cb7eb8c9Sopenharmony_ci 53cb7eb8c9Sopenharmony_ciclass DaemonStubImpl : public DaemonStub { 54cb7eb8c9Sopenharmony_cipublic: 55cb7eb8c9Sopenharmony_ci DaemonStubImpl() = default; 56cb7eb8c9Sopenharmony_ci ~DaemonStubImpl() override {} 57cb7eb8c9Sopenharmony_ci int32_t OpenP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) override 58cb7eb8c9Sopenharmony_ci { 59cb7eb8c9Sopenharmony_ci return 0; 60cb7eb8c9Sopenharmony_ci } 61cb7eb8c9Sopenharmony_ci 62cb7eb8c9Sopenharmony_ci int32_t CloseP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) override 63cb7eb8c9Sopenharmony_ci { 64cb7eb8c9Sopenharmony_ci return 0; 65cb7eb8c9Sopenharmony_ci } 66cb7eb8c9Sopenharmony_ci 67cb7eb8c9Sopenharmony_ci int32_t OpenP2PConnectionEx(const std::string &networkId, sptr<IFileDfsListener> remoteReverseObj) override 68cb7eb8c9Sopenharmony_ci { 69cb7eb8c9Sopenharmony_ci return 0; 70cb7eb8c9Sopenharmony_ci } 71cb7eb8c9Sopenharmony_ci 72cb7eb8c9Sopenharmony_ci int32_t CloseP2PConnectionEx(const std::string &networkId) override 73cb7eb8c9Sopenharmony_ci { 74cb7eb8c9Sopenharmony_ci return 0; 75cb7eb8c9Sopenharmony_ci } 76cb7eb8c9Sopenharmony_ci 77cb7eb8c9Sopenharmony_ci int32_t PrepareSession(const std::string &srcUri, 78cb7eb8c9Sopenharmony_ci const std::string &dstUri, 79cb7eb8c9Sopenharmony_ci const std::string &srcDeviceId, 80cb7eb8c9Sopenharmony_ci const sptr<IRemoteObject> &listener, 81cb7eb8c9Sopenharmony_ci HmdfsInfo &info) override 82cb7eb8c9Sopenharmony_ci { 83cb7eb8c9Sopenharmony_ci return 0; 84cb7eb8c9Sopenharmony_ci } 85cb7eb8c9Sopenharmony_ci 86cb7eb8c9Sopenharmony_ci int32_t CancelCopyTask(const std::string &sessionName) override 87cb7eb8c9Sopenharmony_ci { 88cb7eb8c9Sopenharmony_ci return 0; 89cb7eb8c9Sopenharmony_ci } 90cb7eb8c9Sopenharmony_ci 91cb7eb8c9Sopenharmony_ci int32_t RequestSendFile(const std::string &srcUri, 92cb7eb8c9Sopenharmony_ci const std::string &dstPath, 93cb7eb8c9Sopenharmony_ci const std::string &remoteDeviceId, 94cb7eb8c9Sopenharmony_ci const std::string &sessionName) override 95cb7eb8c9Sopenharmony_ci { 96cb7eb8c9Sopenharmony_ci return 0; 97cb7eb8c9Sopenharmony_ci } 98cb7eb8c9Sopenharmony_ci 99cb7eb8c9Sopenharmony_ci int32_t GetRemoteCopyInfo(const std::string &srcUri, bool &isFile, bool &isDir) override 100cb7eb8c9Sopenharmony_ci { 101cb7eb8c9Sopenharmony_ci return 0; 102cb7eb8c9Sopenharmony_ci } 103cb7eb8c9Sopenharmony_ci 104cb7eb8c9Sopenharmony_ci int32_t PushAsset(int32_t userId, 105cb7eb8c9Sopenharmony_ci const sptr<AssetObj> &assetObj, 106cb7eb8c9Sopenharmony_ci const sptr<IAssetSendCallback> &sendCallback) override 107cb7eb8c9Sopenharmony_ci { 108cb7eb8c9Sopenharmony_ci return 0; 109cb7eb8c9Sopenharmony_ci } 110cb7eb8c9Sopenharmony_ci 111cb7eb8c9Sopenharmony_ci int32_t RegisterAssetCallback(const sptr<IAssetRecvCallback> &recvCallback) override 112cb7eb8c9Sopenharmony_ci { 113cb7eb8c9Sopenharmony_ci return 0; 114cb7eb8c9Sopenharmony_ci } 115cb7eb8c9Sopenharmony_ci 116cb7eb8c9Sopenharmony_ci int32_t UnRegisterAssetCallback(const sptr<IAssetRecvCallback> &recvCallback) override 117cb7eb8c9Sopenharmony_ci { 118cb7eb8c9Sopenharmony_ci return 0; 119cb7eb8c9Sopenharmony_ci } 120cb7eb8c9Sopenharmony_ci}; 121cb7eb8c9Sopenharmony_ci 122cb7eb8c9Sopenharmony_civoid HandleOpenP2PConnectionFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, 123cb7eb8c9Sopenharmony_ci const uint8_t *data, 124cb7eb8c9Sopenharmony_ci size_t size) 125cb7eb8c9Sopenharmony_ci{ 126cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_OPEN_P2P_CONNECTION); 127cb7eb8c9Sopenharmony_ci MessageParcel datas; 128cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 129cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 130cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 131cb7eb8c9Sopenharmony_ci MessageParcel reply; 132cb7eb8c9Sopenharmony_ci MessageOption option; 133cb7eb8c9Sopenharmony_ci 134cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 135cb7eb8c9Sopenharmony_ci} 136cb7eb8c9Sopenharmony_ci 137cb7eb8c9Sopenharmony_civoid HandleCloseP2PConnectionFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, 138cb7eb8c9Sopenharmony_ci const uint8_t *data, 139cb7eb8c9Sopenharmony_ci size_t size) 140cb7eb8c9Sopenharmony_ci{ 141cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_CLOSE_P2P_CONNECTION); 142cb7eb8c9Sopenharmony_ci MessageParcel datas; 143cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 144cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 145cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 146cb7eb8c9Sopenharmony_ci MessageParcel reply; 147cb7eb8c9Sopenharmony_ci MessageOption option; 148cb7eb8c9Sopenharmony_ci 149cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 150cb7eb8c9Sopenharmony_ci} 151cb7eb8c9Sopenharmony_ci 152cb7eb8c9Sopenharmony_civoid HandleOpenP2PConnectionExFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, 153cb7eb8c9Sopenharmony_ci const uint8_t *data, 154cb7eb8c9Sopenharmony_ci size_t size) 155cb7eb8c9Sopenharmony_ci{ 156cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_OPEN_P2P_CONNECTION_EX); 157cb7eb8c9Sopenharmony_ci MessageParcel datas; 158cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 159cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 160cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 161cb7eb8c9Sopenharmony_ci MessageParcel reply; 162cb7eb8c9Sopenharmony_ci MessageOption option; 163cb7eb8c9Sopenharmony_ci 164cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 165cb7eb8c9Sopenharmony_ci} 166cb7eb8c9Sopenharmony_ci 167cb7eb8c9Sopenharmony_civoid HandleCloseP2PConnectionExFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, 168cb7eb8c9Sopenharmony_ci const uint8_t *data, 169cb7eb8c9Sopenharmony_ci size_t size) 170cb7eb8c9Sopenharmony_ci{ 171cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_CLOSE_P2P_CONNECTION_EX); 172cb7eb8c9Sopenharmony_ci MessageParcel datas; 173cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 174cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 175cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 176cb7eb8c9Sopenharmony_ci MessageParcel reply; 177cb7eb8c9Sopenharmony_ci MessageOption option; 178cb7eb8c9Sopenharmony_ci 179cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 180cb7eb8c9Sopenharmony_ci} 181cb7eb8c9Sopenharmony_ci 182cb7eb8c9Sopenharmony_civoid HandlePrepareSessionFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, const uint8_t *data, size_t size) 183cb7eb8c9Sopenharmony_ci{ 184cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_PREPARE_SESSION); 185cb7eb8c9Sopenharmony_ci MessageParcel datas; 186cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 187cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 188cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 189cb7eb8c9Sopenharmony_ci MessageParcel reply; 190cb7eb8c9Sopenharmony_ci MessageOption option; 191cb7eb8c9Sopenharmony_ci 192cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 193cb7eb8c9Sopenharmony_ci} 194cb7eb8c9Sopenharmony_ci 195cb7eb8c9Sopenharmony_civoid HandleCancelCopyTaskFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, const uint8_t *data, size_t size) 196cb7eb8c9Sopenharmony_ci{ 197cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_CANCEL_COPY_TASK); 198cb7eb8c9Sopenharmony_ci MessageParcel datas; 199cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 200cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 201cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 202cb7eb8c9Sopenharmony_ci MessageParcel reply; 203cb7eb8c9Sopenharmony_ci MessageOption option; 204cb7eb8c9Sopenharmony_ci 205cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 206cb7eb8c9Sopenharmony_ci} 207cb7eb8c9Sopenharmony_ci 208cb7eb8c9Sopenharmony_civoid HandleRequestSendFileFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, 209cb7eb8c9Sopenharmony_ci const uint8_t *data, 210cb7eb8c9Sopenharmony_ci size_t size) 211cb7eb8c9Sopenharmony_ci{ 212cb7eb8c9Sopenharmony_ci OHOS::UID = DAEMON_UID; 213cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_REQUEST_SEND_FILE); 214cb7eb8c9Sopenharmony_ci MessageParcel datas; 215cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 216cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 217cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 218cb7eb8c9Sopenharmony_ci MessageParcel reply; 219cb7eb8c9Sopenharmony_ci MessageOption option; 220cb7eb8c9Sopenharmony_ci 221cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 222cb7eb8c9Sopenharmony_ci} 223cb7eb8c9Sopenharmony_ci 224cb7eb8c9Sopenharmony_civoid HandleGetRemoteCopyInfoFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, 225cb7eb8c9Sopenharmony_ci const uint8_t *data, 226cb7eb8c9Sopenharmony_ci size_t size) 227cb7eb8c9Sopenharmony_ci{ 228cb7eb8c9Sopenharmony_ci OHOS::UID = DAEMON_UID; 229cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_GET_REMOTE_COPY_INFO); 230cb7eb8c9Sopenharmony_ci MessageParcel datas; 231cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 232cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 233cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 234cb7eb8c9Sopenharmony_ci MessageParcel reply; 235cb7eb8c9Sopenharmony_ci MessageOption option; 236cb7eb8c9Sopenharmony_ci 237cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 238cb7eb8c9Sopenharmony_ci} 239cb7eb8c9Sopenharmony_ci 240cb7eb8c9Sopenharmony_civoid HandlePushAssetFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, const uint8_t *data, size_t size) 241cb7eb8c9Sopenharmony_ci{ 242cb7eb8c9Sopenharmony_ci OHOS::UID = DATA_UID; 243cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_PUSH_ASSET); 244cb7eb8c9Sopenharmony_ci MessageParcel datas; 245cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 246cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 247cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 248cb7eb8c9Sopenharmony_ci MessageParcel reply; 249cb7eb8c9Sopenharmony_ci MessageOption option; 250cb7eb8c9Sopenharmony_ci 251cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 252cb7eb8c9Sopenharmony_ci} 253cb7eb8c9Sopenharmony_ci 254cb7eb8c9Sopenharmony_civoid HandleRegisterRecvCallbackFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, 255cb7eb8c9Sopenharmony_ci const uint8_t *data, 256cb7eb8c9Sopenharmony_ci size_t size) 257cb7eb8c9Sopenharmony_ci{ 258cb7eb8c9Sopenharmony_ci OHOS::UID = DATA_UID; 259cb7eb8c9Sopenharmony_ci uint32_t code = static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_REGISTER_ASSET_CALLBACK); 260cb7eb8c9Sopenharmony_ci MessageParcel datas; 261cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 262cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 263cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 264cb7eb8c9Sopenharmony_ci MessageParcel reply; 265cb7eb8c9Sopenharmony_ci MessageOption option; 266cb7eb8c9Sopenharmony_ci 267cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 268cb7eb8c9Sopenharmony_ci} 269cb7eb8c9Sopenharmony_ci 270cb7eb8c9Sopenharmony_civoid HandleUnRegisterRecvCallbackFuzzTest(std::shared_ptr<DaemonStub> daemonStubPtr, 271cb7eb8c9Sopenharmony_ci const uint8_t *data, 272cb7eb8c9Sopenharmony_ci size_t size) 273cb7eb8c9Sopenharmony_ci{ 274cb7eb8c9Sopenharmony_ci OHOS::UID = DATA_UID; 275cb7eb8c9Sopenharmony_ci uint32_t code = 276cb7eb8c9Sopenharmony_ci static_cast<uint32_t>(DistributedFileDaemonInterfaceCode::DISTRIBUTED_FILE_UN_REGISTER_ASSET_CALLBACK); 277cb7eb8c9Sopenharmony_ci MessageParcel datas; 278cb7eb8c9Sopenharmony_ci datas.WriteInterfaceToken(DaemonStub::GetDescriptor()); 279cb7eb8c9Sopenharmony_ci datas.WriteBuffer(data, size); 280cb7eb8c9Sopenharmony_ci datas.RewindRead(0); 281cb7eb8c9Sopenharmony_ci MessageParcel reply; 282cb7eb8c9Sopenharmony_ci MessageOption option; 283cb7eb8c9Sopenharmony_ci 284cb7eb8c9Sopenharmony_ci daemonStubPtr->OnRemoteRequest(code, datas, reply, option); 285cb7eb8c9Sopenharmony_ci} 286cb7eb8c9Sopenharmony_ci 287cb7eb8c9Sopenharmony_civoid SetAccessTokenPermission() 288cb7eb8c9Sopenharmony_ci{ 289cb7eb8c9Sopenharmony_ci uint64_t tokenId; 290cb7eb8c9Sopenharmony_ci const char *perms[1]; 291cb7eb8c9Sopenharmony_ci perms[0] = "ohos.permission.DISTRIBUTED_DATASYNC"; 292cb7eb8c9Sopenharmony_ci 293cb7eb8c9Sopenharmony_ci NativeTokenInfoParams infoInstance = { 294cb7eb8c9Sopenharmony_ci .dcapsNum = 0, 295cb7eb8c9Sopenharmony_ci .permsNum = 1, 296cb7eb8c9Sopenharmony_ci .aclsNum = 0, 297cb7eb8c9Sopenharmony_ci .dcaps = nullptr, 298cb7eb8c9Sopenharmony_ci .perms = perms, 299cb7eb8c9Sopenharmony_ci .acls = nullptr, 300cb7eb8c9Sopenharmony_ci .processName = "distributdFileDaemonstubFuzzer", 301cb7eb8c9Sopenharmony_ci .aplStr = "system_basic", 302cb7eb8c9Sopenharmony_ci }; 303cb7eb8c9Sopenharmony_ci tokenId = GetAccessTokenId(&infoInstance); 304cb7eb8c9Sopenharmony_ci if (tokenId == 0) { 305cb7eb8c9Sopenharmony_ci LOGE("Get Acess Token Id Failed"); 306cb7eb8c9Sopenharmony_ci return; 307cb7eb8c9Sopenharmony_ci } 308cb7eb8c9Sopenharmony_ci int ret = SetSelfTokenID(tokenId); 309cb7eb8c9Sopenharmony_ci if (ret != 0) { 310cb7eb8c9Sopenharmony_ci LOGE("Set Acess Token Id Failed"); 311cb7eb8c9Sopenharmony_ci return; 312cb7eb8c9Sopenharmony_ci } 313cb7eb8c9Sopenharmony_ci ret = Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); 314cb7eb8c9Sopenharmony_ci if (ret < 0) { 315cb7eb8c9Sopenharmony_ci LOGE("Reload Native Token Info Failed"); 316cb7eb8c9Sopenharmony_ci return; 317cb7eb8c9Sopenharmony_ci } 318cb7eb8c9Sopenharmony_ci} 319cb7eb8c9Sopenharmony_ci} // namespace OHOS 320cb7eb8c9Sopenharmony_ci 321cb7eb8c9Sopenharmony_ci/* Fuzzer entry point */ 322cb7eb8c9Sopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 323cb7eb8c9Sopenharmony_ci{ 324cb7eb8c9Sopenharmony_ci /* Run your code on data */ 325cb7eb8c9Sopenharmony_ci if (data == nullptr) { 326cb7eb8c9Sopenharmony_ci return 0; 327cb7eb8c9Sopenharmony_ci } 328cb7eb8c9Sopenharmony_ci 329cb7eb8c9Sopenharmony_ci /* Validate the length of size */ 330cb7eb8c9Sopenharmony_ci if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) { 331cb7eb8c9Sopenharmony_ci return 0; 332cb7eb8c9Sopenharmony_ci } 333cb7eb8c9Sopenharmony_ci OHOS::SetAccessTokenPermission(); 334cb7eb8c9Sopenharmony_ci auto daemonStubPtr = std::make_shared<OHOS::DaemonStubImpl>(); 335cb7eb8c9Sopenharmony_ci OHOS::HandleOpenP2PConnectionFuzzTest(daemonStubPtr, data, size); 336cb7eb8c9Sopenharmony_ci OHOS::HandleCloseP2PConnectionFuzzTest(daemonStubPtr, data, size); 337cb7eb8c9Sopenharmony_ci OHOS::HandlePrepareSessionFuzzTest(daemonStubPtr, data, size); 338cb7eb8c9Sopenharmony_ci OHOS::HandleRequestSendFileFuzzTest(daemonStubPtr, data, size); 339cb7eb8c9Sopenharmony_ci OHOS::HandleOpenP2PConnectionExFuzzTest(daemonStubPtr, data, size); 340cb7eb8c9Sopenharmony_ci OHOS::HandleCloseP2PConnectionExFuzzTest(daemonStubPtr, data, size); 341cb7eb8c9Sopenharmony_ci OHOS::HandleCancelCopyTaskFuzzTest(daemonStubPtr, data, size); 342cb7eb8c9Sopenharmony_ci OHOS::HandleGetRemoteCopyInfoFuzzTest(daemonStubPtr, data, size); 343cb7eb8c9Sopenharmony_ci OHOS::HandlePushAssetFuzzTest(daemonStubPtr, data, size); 344cb7eb8c9Sopenharmony_ci OHOS::HandleRegisterRecvCallbackFuzzTest(daemonStubPtr, data, size); 345cb7eb8c9Sopenharmony_ci OHOS::HandleUnRegisterRecvCallbackFuzzTest(daemonStubPtr, data, size); 346cb7eb8c9Sopenharmony_ci return 0; 347cb7eb8c9Sopenharmony_ci} 348