111fccf17Sopenharmony_ci/* 211fccf17Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 311fccf17Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 411fccf17Sopenharmony_ci * you may not use this file except in compliance with the License. 511fccf17Sopenharmony_ci * You may obtain a copy of the License at 611fccf17Sopenharmony_ci * 711fccf17Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 811fccf17Sopenharmony_ci * 911fccf17Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1011fccf17Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1111fccf17Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1211fccf17Sopenharmony_ci * See the License for the specific language governing permissions and 1311fccf17Sopenharmony_ci * limitations under the License. 1411fccf17Sopenharmony_ci */ 1511fccf17Sopenharmony_ci 1611fccf17Sopenharmony_ci#include "createcdmasms_fuzzer.h" 1711fccf17Sopenharmony_ci 1811fccf17Sopenharmony_ci#include <cstddef> 1911fccf17Sopenharmony_ci#include <cstdint> 2011fccf17Sopenharmony_ci 2111fccf17Sopenharmony_ci#include "hril_manager.h" 2211fccf17Sopenharmony_ci#include "hril_sms.h" 2311fccf17Sopenharmony_ci#include "system_ability_definition.h" 2411fccf17Sopenharmony_ci 2511fccf17Sopenharmony_ciusing namespace OHOS::Telephony; 2611fccf17Sopenharmony_cinamespace OHOS { 2711fccf17Sopenharmony_ciconstexpr int32_t SLOT_NUM = 2; 2811fccf17Sopenharmony_ci 2911fccf17Sopenharmony_civoid DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) 3011fccf17Sopenharmony_ci{ 3111fccf17Sopenharmony_ci if (data == nullptr || size == 0) { 3211fccf17Sopenharmony_ci return; 3311fccf17Sopenharmony_ci } 3411fccf17Sopenharmony_ci int32_t slotId = static_cast<int32_t>(size % SLOT_NUM); 3511fccf17Sopenharmony_ci OHOS::HDI::Ril::V1_1::SmsMessageIOInfo message; 3611fccf17Sopenharmony_ci std::string pdu(reinterpret_cast<const char *>(data), size); 3711fccf17Sopenharmony_ci message.pdu = pdu; 3811fccf17Sopenharmony_ci HRilManager::manager_->AddCdmaSimMessage(slotId, size, message); 3911fccf17Sopenharmony_ci return; 4011fccf17Sopenharmony_ci} 4111fccf17Sopenharmony_ci} // namespace OHOS 4211fccf17Sopenharmony_ci 4311fccf17Sopenharmony_ci/* Fuzzer entry point */ 4411fccf17Sopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 4511fccf17Sopenharmony_ci{ 4611fccf17Sopenharmony_ci /* Run your code on data */ 4711fccf17Sopenharmony_ci OHOS::DoSomethingInterestingWithMyAPI(data, size); 4811fccf17Sopenharmony_ci return 0; 4911fccf17Sopenharmony_ci} 50