From 2fbaaac8657156fdc8b98709d204d9354d905801 Mon Sep 17 00:00:00 2001 From: pwx1285814 Date: Thu, 7 Nov 2024 15:35:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dfuzz=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pwx1285814 Change-Id: I765a5da6615b5604b8bc3e576ec4707fc8c21862 --- .../onremotesourcesvrdied_fuzzer.cpp | 3 +- .../registerpluginlistener_fuzzer.cpp | 24 +++++- .../screentransport/test/fuzztest/BUILD.gn | 4 +- .../onbufferavailable_fuzzer/BUILD.gn | 77 ------------------- .../onbufferavailable_fuzzer/corpus/init | 14 ---- .../onbufferavailable_fuzzer.cpp | 54 ------------- .../onbufferavailable_fuzzer.h | 21 ----- .../onbufferavailable_fuzzer/project.xml | 25 ------ .../onbufferavailable_fuzzer/BUILD.gn | 77 ------------------- .../onbufferavailable_fuzzer/corpus/init | 14 ---- .../onbufferavailable_fuzzer.cpp | 46 ----------- .../onbufferavailable_fuzzer.h | 21 ----- .../onbufferavailable_fuzzer/project.xml | 25 ------ .../onoutputformatchanged_fuzzer.cpp | 13 +++- 14 files changed, 33 insertions(+), 385 deletions(-) delete mode 100644 services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn delete mode 100644 services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/corpus/init delete mode 100644 services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp delete mode 100644 services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h delete mode 100644 services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/project.xml delete mode 100644 services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn delete mode 100644 services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/corpus/init delete mode 100644 services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp delete mode 100644 services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h delete mode 100644 services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp index 9f6d358a..b4eec5ff 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp @@ -37,7 +37,8 @@ void OnRemoteSourceSvrDiedFuzzTest(const uint8_t* data, size_t size) return; } - sptr remoteObject = systemAbilityManager->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); + int32_t saId = *(reinterpret_cast(data)); + sptr remoteObject = systemAbilityManager->GetSystemAbility(saId); if (remoteObject == nullptr) { return; } diff --git a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp index 87b3881b..102c094d 100644 --- a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp +++ b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp @@ -36,13 +36,31 @@ public: void RegisterPluginListenerFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size == 0)) { + if ((data == nullptr) || (size < sizeof(int32_t))) { return; } - DHType dhType = DHType::SCREEN; - std::shared_ptr listener = std::make_shared(dhType); + int32_t i = 0; + std::unordered_map dhTypeMap; + dhTypeMap[i++] = DHType::UNKNOWN; + dhTypeMap[i++] = DHType::CAMERA; + dhTypeMap[i++] = DHType::AUDIO; + dhTypeMap[i++] = DHType::SCREEN; + dhTypeMap[i++] = DHType::GPS; + dhTypeMap[i++] = DHType::INPUT; + dhTypeMap[i++] = DHType::HFP; + dhTypeMap[i++] = DHType::A2D; + dhTypeMap[i++] = DHType::VIRMODEM_AUDIO; + dhTypeMap[i++] = DHType::MODEM; + dhTypeMap[i++] = DHType::MAX_DH; + int32_t key = *(reinterpret_cast(data)) % static_cast(dhTypeMap.size()); + if (dhTypeMap.count(key) == 0) { + return; + } + + DHType dhType = dhTypeMap[key]; + std::shared_ptr listener = std::make_shared(dhType); DScreenHandler::GetInstance().RegisterPluginListener(listener); } } // namespace DistributedHardware diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn index 0bf5bdfc..c69aa5d0 100644 --- a/services/screentransport/test/fuzztest/BUILD.gn +++ b/services/screentransport/test/fuzztest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -15,8 +15,6 @@ group("fuzztest") { testonly = true deps = [ - "screensinkprocessor/onbufferavailable_fuzzer:fuzztest", - "screensourceprocessor/onbufferavailable_fuzzer:fuzztest", "screensourceprocessor/onerror_fuzzer:fuzztest", "screensourceprocessor/oninputbufferavailable_fuzzer:fuzztest", "screensourceprocessor/onoutputbufferavailable_fuzzer:fuzztest", diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn deleted file mode 100644 index 906cbcf7..00000000 --- a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("OnBufferAvailableFuzzTest") { - module_out_path = "${fuzz_test_path}/imagesinkdecoder" - - fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer" - - include_dirs = [ - "${common_path}/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/decision_center/include", - "${services_path}/common/imageJpeg/include", - "${services_path}/common/screen_channel/include", - "${services_path}/common/utils/include", - "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensinkprocessor/decoder/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensourcetrans/include", - "${services_path}/screentransport/screensourceprocessor/include", - "${services_path}/screentransport/screensourceprocessor/encoder/include", - "${services_path}/softbusadapter/include", - ] - - configs = - [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - - sources = [ "onbufferavailable_fuzzer.cpp" ] - - deps = [ - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"HandlerOnRemoteSinkSvrDiedFuzzTest\"", - "LOG_DOMAIN=0xD004140", - ] - - external_deps = [ - "av_codec:av_codec_client", - "c_utils:utils", - "distributed_hardware_fwk:distributedhardwareutils", - "distributed_hardware_fwk:libdhfwk_sdk", - "graphic_surface:surface", - "graphic_surface:sync_fence", - "hilog:libhilog", - "ipc:ipc_core", - "json:nlohmann_json_static", - "media_foundation:media_foundation", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":OnBufferAvailableFuzzTest" ] -} -############################################################################### diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/corpus/init deleted file mode 100644 index e4ceac1b..00000000 --- a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/corpus/init +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FUZZ \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp deleted file mode 100644 index 5117323c..00000000 --- a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "onbufferavailable_fuzzer.h" - -#include -#include - -#include "avcodec_common.h" -#include "dscreen_constants.h" -#include "dscreen_errcode.h" -#include "meta/format.h" -#include "iimage_source_processor_listener.h" -#include "screen_sink_trans.h" -#include "image_sink_decoder.h" -#include "image_source_encoder.h" -#include "image_encoder_callback.h" -#include "iscreen_channel_listener.h" - -namespace OHOS { -namespace DistributedHardware { -void OnBufferAvailableFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::shared_ptr listener = std::make_shared(); - std::shared_ptr decoder = std::make_shared(listener); - std::shared_ptr bufferListen = std::make_shared(decoder); - bufferListen->OnBufferAvailable(); -} -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::OnBufferAvailableFuzzTest(data, size); - return 0; -} - diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h deleted file mode 100644 index 325f4c1a..00000000 --- a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ONBUFFERAVAILABLE_FUZZER_H -#define ONBUFFERAVAILABLE_FUZZER_H - -#define FUZZ_PROJECT_NAME "OnBufferAvailable_fuzzer" - -#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/project.xml deleted file mode 100644 index 4fdbc407..00000000 --- a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn deleted file mode 100644 index ae57674d..00000000 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("OnBufferAvailableFuzzTest") { - module_out_path = "${fuzz_test_path}/imagesourceencoder" - - fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer" - - include_dirs = [ - "${common_path}/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/decision_center/include", - "${services_path}/common/imageJpeg/include", - "${services_path}/common/screen_channel/include", - "${services_path}/common/utils/include", - "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensinkprocessor/decoder/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensourcetrans/include", - "${services_path}/screentransport/screensourceprocessor/include", - "${services_path}/screentransport/screensourceprocessor/encoder/include", - "${services_path}/softbusadapter/include", - ] - - configs = - [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - - sources = [ "onbufferavailable_fuzzer.cpp" ] - - deps = [ - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"HandlerOnRemoteSinkSvrDiedFuzzTest\"", - "LOG_DOMAIN=0xD004140", - ] - - external_deps = [ - "av_codec:av_codec_client", - "c_utils:utils", - "distributed_hardware_fwk:distributedhardwareutils", - "distributed_hardware_fwk:libdhfwk_sdk", - "graphic_surface:surface", - "graphic_surface:sync_fence", - "hilog:libhilog", - "ipc:ipc_core", - "json:nlohmann_json_static", - "media_foundation:media_foundation", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":OnBufferAvailableFuzzTest" ] -} -############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/corpus/init deleted file mode 100644 index e4ceac1b..00000000 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/corpus/init +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FUZZ \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp deleted file mode 100644 index 66212842..00000000 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "onbufferavailable_fuzzer.h" - -#include -#include - -#include "image_source_encoder.h" -#include "screen_source_trans.h" - -namespace OHOS { -namespace DistributedHardware { -void OnBufferAvailableFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::shared_ptr listener = std::make_shared(); - std::shared_ptr encoder = std::make_shared(listener); - std::shared_ptr bufferListen = std::make_shared(encoder); - bufferListen->OnBufferAvailable(); -} -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::OnBufferAvailableFuzzTest(data, size); - return 0; -} - diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h deleted file mode 100644 index 7a4f288e..00000000 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ONREMOTESINKSVRDIED_FUZZER_H -#define ONREMOTESINKSVRDIED_FUZZER_H - -#define FUZZ_PROJECT_NAME "onbufferavailable_fuzzer" - -#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/project.xml deleted file mode 100644 index 4fdbc407..00000000 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.cpp index 724f2e81..62dc76c6 100644 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.cpp +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.cpp @@ -18,21 +18,22 @@ #include #include "avcodec_common.h" +#include "avcodec_errors.h" +#include "dscreen_constants.h" #include "dscreen_constants.h" #include "dscreen_errcode.h" -#include "meta/format.h" #include "iimage_source_processor_listener.h" -#include "image_source_encoder.h" #include "image_encoder_callback.h" +#include "image_source_encoder.h" #include "iscreen_channel_listener.h" -#include "avcodec_errors.h" +#include "meta/format.h" #include "screen_source_trans.h" namespace OHOS { namespace DistributedHardware { void OnOutputFormatChangedFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size == 0)) { + if ((data == nullptr) || (size < sizeof(int32_t))) { return; } std::shared_ptr listener = std::make_shared(); @@ -40,6 +41,10 @@ void OnOutputFormatChangedFuzzTest(const uint8_t* data, size_t size) std::shared_ptr encoderCallback = std::make_shared(encoder); Media::Format format; + int32_t width = *(reinterpret_cast(data)); + int32_t height = *(reinterpret_cast(data)); + format.PutIntValue(KEY_WIDTH, width); + format.PutIntValue(KEY_HEIGHT, height); encoderCallback->OnOutputFormatChanged(format); } } // namespace DistributedHardware -- Gitee