111fccf17Sopenharmony_ci/* 211fccf17Sopenharmony_ci * Copyright (c) 2022 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 "simstkproactivenotify_fuzzer.h" 1711fccf17Sopenharmony_ci 1811fccf17Sopenharmony_ci#include <cstddef> 1911fccf17Sopenharmony_ci#include <cstdint> 2011fccf17Sopenharmony_ci 2111fccf17Sopenharmony_ci#include "hril_manager.h" 2211fccf17Sopenharmony_ci#include "hril_notification.h" 2311fccf17Sopenharmony_ci#include "hril_sim.h" 2411fccf17Sopenharmony_ci#include "system_ability_definition.h" 2511fccf17Sopenharmony_ci 2611fccf17Sopenharmony_ciusing namespace OHOS::Telephony; 2711fccf17Sopenharmony_cinamespace OHOS { 2811fccf17Sopenharmony_ciconstexpr int32_t SLOT_NUM = 3; 2911fccf17Sopenharmony_ciconstexpr const char *NUMBER = "123"; 3011fccf17Sopenharmony_ci 3111fccf17Sopenharmony_civoid DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) 3211fccf17Sopenharmony_ci{ 3311fccf17Sopenharmony_ci if (data == nullptr || size == 0) { 3411fccf17Sopenharmony_ci return; 3511fccf17Sopenharmony_ci } 3611fccf17Sopenharmony_ci 3711fccf17Sopenharmony_ci int32_t slotId = static_cast<HRilErrNumber>(size) % SLOT_NUM; 3811fccf17Sopenharmony_ci const uint8_t *response = reinterpret_cast<const uint8_t *>(NUMBER); 3911fccf17Sopenharmony_ci 4011fccf17Sopenharmony_ci struct ReportInfo report; 4111fccf17Sopenharmony_ci report.error = static_cast<HRilErrNumber>(size); 4211fccf17Sopenharmony_ci report.notifyId = HNOTI_SIM_STK_PROACTIVE_NOTIFY; 4311fccf17Sopenharmony_ci report.type = HRIL_NOTIFICATION; 4411fccf17Sopenharmony_ci HRilManager::manager_->OnSimReport(slotId, &report, response, sizeof(char)); 4511fccf17Sopenharmony_ci return; 4611fccf17Sopenharmony_ci} 4711fccf17Sopenharmony_ci} // namespace OHOS 4811fccf17Sopenharmony_ci 4911fccf17Sopenharmony_ci/* Fuzzer entry point */ 5011fccf17Sopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 5111fccf17Sopenharmony_ci{ 5211fccf17Sopenharmony_ci /* Run your code on data */ 5311fccf17Sopenharmony_ci OHOS::DoSomethingInterestingWithMyAPI(data, size); 5411fccf17Sopenharmony_ci return 0; 5511fccf17Sopenharmony_ci} 56