diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn index 19e02b6a45bf0d3f5461781bd8d44a4943900fd1..0c70ef0877467bafe184f7329e0fd48b8970cd50 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn @@ -23,6 +23,9 @@ group("fuzztest") { "dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer:fuzztest", "dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer:fuzztest", "dscreen_sink_proxy/sinkproxydscreennotify_fuzzer:fuzztest", + "dscreen_source_callback/callbackonnotifyregresult_fuzzer:fuzztest", + "dscreen_source_callback/callbackonnotifyunregresult_fuzzer:fuzztest", + "dscreen_source_callback/callbackonremoterequest_fuzzer:fuzztest", "dscreen_source_handler/handlerconfigdistributedhardware_fuzzer:fuzztest", "dscreen_source_handler/handlerinitsource_fuzzer:fuzztest", "dscreen_source_handler/handleronremotesourcesvrdied_fuzzer:fuzztest", diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..52db1b2cd5effdccfdb293bd3434b5eeae882e8f --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn @@ -0,0 +1,73 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("CallBackOnNotifyRegResultFuzzTest") { + module_out_path = "distributed_screen/dscreensourcecallback" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkservice/include", + "${fwk_services_path}/distributedhardwarefwkservice/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "callbackonnotifyregresult_fuzzer.cpp" ] + + deps = [ + "${fwk_services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"CallBackOnNotifyRegResultFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":CallBackOnNotifyRegResultFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..540a86c10e192e901b2770572b29fa882fc240ca --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 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 "callbackonnotifyregresult_fuzzer.h" + +#include +#include +#include + +#include "component_enable.h" +#include "dscreen_constants.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_proxy.h" + +namespace OHOS { +namespace DistributedHardware { +void OnNotifyRegResultFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + int32_t status = *(reinterpret_cast(data)); + std::string dataStr(reinterpret_cast(data), size); + std::shared_ptr callback = std::make_shared(); + + sptr dScreenSourceCallback = new (std::nothrow) DScreenSourceCallback(); + dScreenSourceCallback->PushRegRegisterCallback(reqId, callback); + dScreenSourceCallback->OnNotifyRegResult(devId, dhId, reqId, status, dataStr); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnNotifyRegResultFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..2d909d8c4477332d9bbbabe3deb5aeaa99f30b99 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/callbackonnotifyregresult_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 CALLBACKONNOTIFYREGRESULT_FUZZER_H +#define CALLBACKONNOTIFYREGRESULT_FUZZER_H + +#define FUZZ_PROJECT_NAME "callbackonnotifyregresult_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 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/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1990660529cc278515f7cdb9cd66952318ad41c1 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn @@ -0,0 +1,73 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("CallBackOnNotifyUnregResultFuzzTest") { + module_out_path = "distributed_screen/dscreensourcecallback" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkservice/include", + "${fwk_services_path}/distributedhardwarefwkservice/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "callbackonnotifyunregresult_fuzzer.cpp" ] + + deps = [ + "${fwk_services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"CallBackOnNotifyUnregResultFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":CallBackOnNotifyUnregResultFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1f1bea6f20b2cb418972b59ac19ecd543c214ed3 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022 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 "callbackonnotifyunregresult_fuzzer.h" + +#include +#include +#include + +#include "component_disable.h" +#include "dscreen_constants.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_proxy.h" + +namespace OHOS { +namespace DistributedHardware { +void OnNotifyUnregResultFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + int32_t status = *(reinterpret_cast(data)); + std::string dataStr(reinterpret_cast(data), size); + std::shared_ptr uncallback = std::make_shared(); + + sptr dScreenSourceCallback = new (std::nothrow) DScreenSourceCallback(); + + dScreenSourceCallback->PushUnregisterCallback(reqId, uncallback); + dScreenSourceCallback->OnNotifyUnregResult(devId, dhId, reqId, status, dataStr); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnNotifyUnregResultFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d4d60c9af279504b87ebe285a40ae2f6be964e0c --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/callbackonnotifyunregresult_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 CALLBACKONNOTIFYUNREGRESULT_FUZZER_H +#define CALLBACKONNOTIFYUNREGRESULT_FUZZER_H + +#define FUZZ_PROJECT_NAME "callbackonnotifyunregresult_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 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/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7d0dde8c0129e4f3645ebc5e66c443ecb018ef40 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn @@ -0,0 +1,72 @@ +# Copyright (c) 2022 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( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("CallbackOnRemoteRequestFuzzTest") { + module_out_path = "distributed_screen/dscreensourcecallback" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkservice/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "callbackonremoterequest_fuzzer.cpp" ] + + deps = [ + "${fwk_services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"CallbackOnRemoteRequestFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":CallbackOnRemoteRequestFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7d84b784f2a9ad0771bb6845817f926bfce28426 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022 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 "callbackonremoterequest_fuzzer.h" + +#include +#include +#include + +#include "dscreen_constants.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_callback_stub.h" +#include "dscreen_source_proxy.h" +#include "iremote_object.h" +#include "message_option.h" +#include "message_parcel.h" + +namespace OHOS { +namespace DistributedHardware { +void CallbackOnRemoteRequestFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint32_t))) { + return; + } + + MessageParcel pdata; + MessageParcel reply; + MessageOption option; + uint32_t code = *(reinterpret_cast(data)) % 2; + int32_t status = *(reinterpret_cast(data)); + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + std::string dataStr(reinterpret_cast(data), size); + pdata.WriteInt32(status); + pdata.WriteString(devId); + pdata.WriteString(dhId); + pdata.WriteString(reqId); + pdata.WriteString(dataStr); + + sptr dScreenSourceCallback = new (std::nothrow) DScreenSourceCallback(); + dScreenSourceCallback->OnRemoteRequest(code, pdata, reply, option); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::CallbackOnRemoteRequestFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..05ff48f27fd53efed96bdb0e57e66972dd711d03 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/callbackonremoterequest_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 CALLBACKONREMOTEREQUEST_FUZZER_H +#define CALLBACKONREMOTEREQUEST_FUZZER_H + +#define FUZZ_PROJECT_NAME "callbackonremoterequest_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2022 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/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn index ae81ebc8337f2e7ae1220e9088d36521f37e1d9e..33e0c875ad0c8c4b62d3135455338bdc56cd395a 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn @@ -53,7 +53,10 @@ ohos_unittest("ScreenSinkTest") { "//third_party/googletest:gtest_main", ] - external_deps = [ "c_utils:utils" ] + external_deps = [ + "c_utils:utils", + "samgr:samgr_proxy", + ] } group("screen_sink_test") { diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp index 7fa8be8788f22923c77257c6ce9d87641d44a20d..f6d927560d3dd1b9a41bcdf98cbabc54d39a1350 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp @@ -35,6 +35,7 @@ void DScreenSinkHandlerTest::TearDown(void) { DScreenSinkHandler::GetInstance().ReleaseSink(); } + /** * @tc.name: LocalHardware_001 * @tc.desc: Verify the SubscribeLocalHardware function. @@ -47,8 +48,33 @@ HWTEST_F(DScreenSinkHandlerTest, LocalHardware_001, TestSize.Level1) const std::string param = "DScreenSinkHandlerTest"; int32_t ret = DScreenSinkHandler::GetInstance().SubscribeLocalHardware(dhId, param); EXPECT_EQ(DH_SUCCESS, ret); + ret = DScreenSinkHandler::GetInstance().UnsubscribeLocalHardware(dhId); EXPECT_EQ(DH_SUCCESS, ret); + + DScreenSinkHandler::GetInstance().dScreenSinkProxy_ = nullptr; + ret = DScreenSinkHandler::GetInstance().UnsubscribeLocalHardware(dhId); + EXPECT_EQ(ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT, ret); +} + +/** + * @tc.name: OnRemoteSinkSvrDied_001 + * @tc.desc: Verify the OnRemoteSinkSvrDied function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSinkHandlerTest, OnRemoteSinkSvrDied_001, TestSize.Level1) +{ + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + + sptr remoteObject = + samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); + + wptr remote(remoteObject); + + DScreenSinkHandler::GetInstance().sinkSvrRecipient_->OnRemoteDied(remote); + EXPECT_EQ(nullptr, DScreenSinkHandler::GetInstance().dScreenSinkProxy_); } } } \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn index a7a9126b7d9e48e0b8057886328f9537d3548d07..20213111db31ee869df0d82beebcbf9eeeb08a81 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn @@ -21,6 +21,7 @@ config("module_private_config") { visibility = [ ":*" ] include_dirs = [ "//third_party/json/include", + "//utils/system/safwk/native/include", "${fwk_common_path}/utils/include", "${fwk_utils_path}/include", ] @@ -61,6 +62,7 @@ ohos_unittest("ScreenSourceTest") { external_deps = [ "c_utils:utils", "ipc:ipc_core", + "samgr:samgr_proxy", ] } diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp index 86903c93b11e557f6699f63e83bc9618b05053d0..db5d952c2815c8078a771f768ce35b7259cbde0a 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp @@ -15,6 +15,9 @@ #define private public #include "dscreen_source_handler_test.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" +#include "dscreen_constants.h" #undef private using namespace testing; @@ -52,12 +55,82 @@ HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_001, TestSize.Lev std::shared_ptr callback = std::make_shared(); int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(DH_SUCCESS, ret); +} +/** + * @tc.name: RegisterDistributedHardware_002 + * @tc.desc: Verify the RegisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_002, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + EnableParam param; + param.version = "1"; + param.attrs = "attrs"; + std::shared_ptr callback = std::make_shared(); + DScreenSourceHandler::GetInstance().dScreenSourceProxy_ = nullptr; + int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); + EXPECT_EQ(ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT, ret); +} + +/** + * @tc.name: RegisterDistributedHardware_003 + * @tc.desc: Verify the RegisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_003, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + EnableParam param; + param.version = "1"; + param.attrs = "attrs"; + std::shared_ptr callback = std::make_shared(); DScreenSourceHandler::GetInstance().dScreenSourceCallback_ = nullptr; - ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); + int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT, ret); } +/** + * @tc.name: RegisterDistributedHardware_004 + * @tc.desc: Verify the RegisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_004, TestSize.Level1) +{ + const std::string devId = ""; + const std::string dhId = ""; + EnableParam param; + param.version = "1"; + param.attrs = "attrs"; + std::shared_ptr callback = std::make_shared(); + int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); + EXPECT_EQ(ERR_DH_SCREEN_STRING_PARAM_EMPTY, ret); +} + +/** + * @tc.name: RegisterDistributedHardware_005 + * @tc.desc: Verify the RegisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_005, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + EnableParam param; + param.version = "1"; + param.attrs = "attrs"; + std::shared_ptr callback = nullptr; + int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); + EXPECT_EQ(ERR_DH_SCREEN_REGISTER_CALLBACK_NOT_INIT, ret); +} + /** * @tc.name: UnregisterDistributedHardware_001 * @tc.desc: Verify the UnregisterDistributedHardware function. @@ -70,7 +143,7 @@ HWTEST_F(DScreenSourceHandlerTest, UnregisterDistributedHardware_001, TestSize.L const std::string dhId = "dhId"; std::shared_ptr callback = std::make_shared(); if (DScreenSourceHandler::GetInstance().dScreenSourceCallback_ == nullptr) { - DScreenSourceHandler::GetInstance().dScreenSourceCallback_ = new (std::nothrow) DScreenSourceCallback();; + DScreenSourceHandler::GetInstance().dScreenSourceCallback_ = new (std::nothrow) DScreenSourceCallback(); } int32_t ret = DScreenSourceHandler::GetInstance().UnregisterDistributedHardware(devId, dhId, callback); EXPECT_EQ(ERR_DH_SCREEN_SA_DISABLE_FAILED, ret); @@ -83,6 +156,36 @@ HWTEST_F(DScreenSourceHandlerTest, UnregisterDistributedHardware_001, TestSize.L * @tc.require: Issue Number */ HWTEST_F(DScreenSourceHandlerTest, UnregisterDistributedHardware_002, TestSize.Level1) +{ + const std::string devId = ""; + const std::string dhId = ""; + std::shared_ptr callback = std::make_shared(); + int32_t ret = DScreenSourceHandler::GetInstance().UnregisterDistributedHardware(devId, dhId, callback); + EXPECT_EQ(ERR_DH_SCREEN_STRING_PARAM_EMPTY, ret); +} + +/** + * @tc.name: UnregisterDistributedHardware_003 + * @tc.desc: Verify the UnregisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, UnregisterDistributedHardware_003, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + std::shared_ptr callback = nullptr; + int32_t ret = DScreenSourceHandler::GetInstance().UnregisterDistributedHardware(devId, dhId, callback); + EXPECT_EQ(ERR_DH_SCREEN_REGISTER_CALLBACK_NOT_INIT, ret); +} + +/** + * @tc.name: UnregisterDistributedHardware_004 + * @tc.desc: Verify the UnregisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, UnregisterDistributedHardware_004, TestSize.Level1) { const std::string devId = "devId"; const std::string dhId = "dhId"; @@ -93,6 +196,23 @@ HWTEST_F(DScreenSourceHandlerTest, UnregisterDistributedHardware_002, TestSize.L EXPECT_EQ(ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT, ret); } +/** + * @tc.name: UnregisterDistributedHardware_005 + * @tc.desc: Verify the UnregisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, UnregisterDistributedHardware_005, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + std::shared_ptr callback = std::make_shared(); + DScreenSourceHandler::GetInstance().dScreenSourceProxy_ = nullptr; + + int32_t ret = DScreenSourceHandler::GetInstance().UnregisterDistributedHardware(devId, dhId, callback); + EXPECT_EQ(ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT, ret); +} + /** * @tc.name: ConfigDistributedHardware_001 * @tc.desc: Verify the ConfigDistributedHardware function. @@ -109,5 +229,35 @@ HWTEST_F(DScreenSourceHandlerTest, ConfigDistributedHardware_001, TestSize.Level int32_t ret = DScreenSourceHandler::GetInstance().ConfigDistributedHardware(devId, dhId, key, value); EXPECT_EQ(DH_SUCCESS, ret); } + +/** + * @tc.name: ReleaseSource_001 + * @tc.desc: Verify the ReleaseSource function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, ReleaseSource_001, TestSize.Level1) +{ + DScreenSourceHandler::GetInstance().dScreenSourceProxy_ = nullptr; + int32_t ret = DScreenSourceHandler::GetInstance().ReleaseSource(); + EXPECT_EQ(ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT, ret); +} + +/** + * @tc.name: OnRemoteDied_001 + * @tc.desc: Verify the OnRemoteDied function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, OnRemoteDied_001, TestSize.Level1) +{ + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + wptr remote(remoteObject); + DScreenSourceHandler::GetInstance().sourceSvrRecipient_->OnRemoteDied(remote); + EXPECT_EQ(nullptr, DScreenSourceHandler::GetInstance().dScreenSourceProxy_); +} } } \ No newline at end of file diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/src/screenregion_test.cpp b/services/screenservice/test/unittest/sinkservice/screenregionmgr/src/screenregion_test.cpp index cdbafde3c318baa6f0e59c826aa44f3ac6a993b3..ab31d9de57a9a09dd3f830771ba814e5ac9a289d 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/src/screenregion_test.cpp +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/src/screenregion_test.cpp @@ -33,9 +33,124 @@ void ScreenRegionTest::SetUp(void) screenRegion_ = std::make_shared(remoteDevId, screenId, displayId); } -void ScreenRegionTest::TearDown(void) +void ScreenRegionTest::TearDown(void) {} + +/** + * @tc.name: OnTransError_001 + * @tc.desc: Verify the OnTransError function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, OnTransError_001, TestSize.Level1) +{ + int32_t err = 0; + const std::string content = "ScreenRegionTest"; + screenRegion_->OnTransError(err, content); + EXPECT_EQ(false, screenRegion_->isRunning); +} + +/** + * @tc.name: SetMapRelation_001 + * @tc.desc: Verify the SetMapRelation function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, SetMapRelation_001, TestSize.Level1) +{ + std::shared_ptr mapRelation = std::make_shared(); + screenRegion_->SetMapRelation(mapRelation); + EXPECT_EQ(mapRelation, screenRegion_->mapRelation_); +} + +/** + * @tc.name: GetScreenId_001 + * @tc.desc: Verify the GetScreenId function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, GetScreenId_001, TestSize.Level1) { - sleep(1); + screenRegion_->screenId_ = 5; + uint64_t ret = screenRegion_->GetScreenId(); + EXPECT_EQ(screenRegion_->screenId_, ret); +} + +/** + * @tc.name: GetDisplayId_001 + * @tc.desc: Verify the GetDisplayId function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, GetDisplayId_001, TestSize.Level1) +{ + screenRegion_->displayId_ = 5; + uint64_t ret = screenRegion_->GetDisplayId(); + EXPECT_EQ(screenRegion_->displayId_, ret); +} + +/** + * @tc.name: GetRemoteDevId_001 + * @tc.desc: Verify the GetRemoteDevId function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, GetRemoteDevId_001, TestSize.Level1) +{ + screenRegion_->remoteDevId_ = "remoteDevId"; + std::string ret = screenRegion_->GetRemoteDevId(); + EXPECT_EQ(screenRegion_->remoteDevId_, ret); +} + +/** + * @tc.name: GetWindowId_001 + * @tc.desc: Verify the GetWindowId function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, GetWindowId_001, TestSize.Level1) +{ + screenRegion_->windowId_ = 5; + int32_t ret = screenRegion_->GetWindowId(); + EXPECT_EQ(screenRegion_->windowId_, ret); +} + +/** + * @tc.name: GetVideoParam_001 + * @tc.desc: Verify the GetVideoParam function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, GetVideoParam_001, TestSize.Level1) +{ + screenRegion_->videoParam_ = std::make_shared(); + std::shared_ptr ret = screenRegion_->GetVideoParam(); + EXPECT_EQ(screenRegion_->videoParam_, ret); +} + +/** + * @tc.name: GetWindowProperty_001 + * @tc.desc: Verify the GetWindowProperty function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, GetWindowProperty_001, TestSize.Level1) +{ + screenRegion_->windowProperty_ = std::make_shared(); + std::shared_ptr ret = screenRegion_->GetWindowProperty(); + EXPECT_EQ(screenRegion_->windowProperty_, ret); +} + +/** + * @tc.name: SetUpWindow_001 + * @tc.desc: Verify the SetUpWindow function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, SetUpWindow_001, TestSize.Level1) +{ + screenRegion_->mapRelation_ = nullptr; + int32_t ret = screenRegion_->SetUpWindow(); + EXPECT_EQ(ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED, ret); } /** @@ -67,6 +182,20 @@ HWTEST_F(ScreenRegionTest, SetUp_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED, ret); } +/** + * @tc.name: SetUp_002 + * @tc.desc: Verify the SetUp function failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenRegionTest, SetUp_002, TestSize.Level1) +{ + screenRegion_->mapRelation_ = nullptr; + int32_t ret = screenRegion_->SetUp(); + + EXPECT_EQ(ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED, ret); +} + /** * @tc.name: Start_001 * @tc.desc: Verify the Start function failed. diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index f600a269b023dc43a6feb268fc598305f6d4483f..e5675465d04f39e6f1b8ead63bf2becbc8b776c3 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -231,12 +231,11 @@ void ImageSourceEncoder::OnOutputBufferAvailable(uint32_t index, Media::AVCodecB } size_t dataSize = static_cast(info.size); - if (dataSize <= 0 || dataSize > DATA_BUFFER_MAX_SIZE) { + if (dataSize == 0 || dataSize > DATA_BUFFER_MAX_SIZE) { DHLOGE("%s:OnOutputBufferAvailable params invalid, size: %d.", LOG_TAG, dataSize); return; } auto dataBuf = std::make_shared(dataSize); - int32_t ret = memcpy_s(dataBuf->Data(), dataBuf->Capacity(), videoSharedMemory_->GetBase(), dataSize); if (ret != EOK) { DHLOGE("%s: Copy data failed.", LOG_TAG);