From 4ace7bfe9a111958f407653bc06aa91c7606fc4f Mon Sep 17 00:00:00 2001 From: w30042960 Date: Sat, 13 Jul 2024 15:06:52 +0800 Subject: [PATCH 1/3] modify log Signed-off-by: w30042960 --- .../fuzztest/onstreamreceived_fuzzer/BUILD.gn | 8 ++-- .../avtransOnSessionClosed_fuzzer.cpp | 2 +- .../avtransOnSessionClosed_fuzzer.h | 2 +- .../avtransonsessionclosed_fuzzer.cpp | 46 +++++++++++++++++++ .../avtransonsessionclosed_fuzzer.h | 21 +++++++++ av_transport/common/src/av_trans_meta.cpp | 33 +++++-------- .../common/src/softbus_channel_adapter.cpp | 4 +- 7 files changed, 87 insertions(+), 29 deletions(-) create mode 100644 av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransonsessionclosed_fuzzer.cpp create mode 100644 av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransonsessionclosed_fuzzer.h diff --git a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/BUILD.gn b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/BUILD.gn index e33b703c..64631566 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/BUILD.gn +++ b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/BUILD.gn @@ -55,7 +55,7 @@ ohos_fuzztest("OnStreamReceivedFuzzTest") { ohos_fuzztest("OnBytesReceivedFuzzTest") { module_out_path = fuzz_test_output_path fuzz_config_file = - "${control_center_path}/test/fuzztest/onstreamreceived_fuzzer" + "${control_center_path}/test/fuzztest/onbytesreceived_fuzzer" include_dirs = [ "include", @@ -90,7 +90,7 @@ ohos_fuzztest("OnBytesReceivedFuzzTest") { ohos_fuzztest("OnSoftbusTimeSyncResultFuzzTest") { module_out_path = fuzz_test_output_path fuzz_config_file = - "${control_center_path}/test/fuzztest/onstreamreceived_fuzzer" + "${control_center_path}/test/fuzztest/onsoftbustimesyncresult_fuzzer" include_dirs = [ "include", @@ -125,7 +125,7 @@ ohos_fuzztest("OnSoftbusTimeSyncResultFuzzTest") { ohos_fuzztest("AVTransOnSessionClosedFuzzTest") { module_out_path = fuzz_test_output_path fuzz_config_file = - "${control_center_path}/test/fuzztest/onstreamreceived_fuzzer" + "${control_center_path}/test/fuzztest/avtransonsessionclosed_fuzzer" include_dirs = [ "include", @@ -140,7 +140,7 @@ ohos_fuzztest("AVTransOnSessionClosedFuzzTest") { "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "avtransOnSessionClosed_fuzzer.cpp" ] + sources = [ "avtransonsessionclosed_fuzzer.cpp" ] deps = [ "${engine_path}/av_sender:distributed_av_sender" ] diff --git a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.cpp b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.cpp index d3ac3c65..dc775aaf 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.cpp +++ b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "avtransOnSessionClosed_fuzzer.h" +#include "avtransonsessionclosed_fuzzer.h" #include #include diff --git a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.h b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.h index 6bc033a6..6e353295 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.h +++ b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.h @@ -16,6 +16,6 @@ #ifndef TEST_AVTRANSONSESSIONCLOSED_FUZZER_H #define TEST_AVTRANSONSESSIONCLOSED_FUZZER_H -#define FUZZ_PROJECT_NAME "avtransOnSessionClosed_fuzzer.cpp" +#define FUZZ_PROJECT_NAME "avtransonsessionclosed_fuzzer.cpp" #endif \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransonsessionclosed_fuzzer.cpp b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransonsessionclosed_fuzzer.cpp new file mode 100644 index 00000000..dc775aaf --- /dev/null +++ b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransonsessionclosed_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 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 "avtransonsessionclosed_fuzzer.h" + +#include +#include +#include +#include + +#include "softbus_channel_adapter.h" + +namespace OHOS { +namespace DistributedHardware { +void AVTransOnSessionClosedFuzzTest(const uint8_t *data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + int32_t sessionId = *(reinterpret_cast(data)); + ShutdownReason reason = *(reinterpret_cast(data)); + + SoftbusChannelAdapter::GetInstance().OnSoftbusChannelClosed(sessionId, reason); +} +} // 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::AVTransOnSessionClosedFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransonsessionclosed_fuzzer.h b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransonsessionclosed_fuzzer.h new file mode 100644 index 00000000..6e353295 --- /dev/null +++ b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransonsessionclosed_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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. + */ + +#ifndef TEST_AVTRANSONSESSIONCLOSED_FUZZER_H +#define TEST_AVTRANSONSESSIONCLOSED_FUZZER_H + +#define FUZZ_PROJECT_NAME "avtransonsessionclosed_fuzzer.cpp" + +#endif \ No newline at end of file diff --git a/av_transport/common/src/av_trans_meta.cpp b/av_transport/common/src/av_trans_meta.cpp index 0724879b..4375e431 100644 --- a/av_transport/common/src/av_trans_meta.cpp +++ b/av_transport/common/src/av_trans_meta.cpp @@ -141,40 +141,31 @@ bool AVTransVideoBufferMeta::UnmarshalVideoMeta(const std::string& jsonStr) if (metaJson == nullptr) { return false; } + cJSON *typeObj = cJSON_GetObjectItemCaseSensitive(metaJson, META_DATA_TYPE.c_str()); - if (typeObj == nullptr || !IsUInt32(metaJson, META_DATA_TYPE)) { - cJSON_Delete(metaJson); - return false; + if (typeObj != nullptr && IsUInt32(metaJson, META_DATA_TYPE)) { + dataType_ = static_cast(typeObj->valueint); } - dataType_ = static_cast(typeObj->valueint); cJSON *timeStampObj = cJSON_GetObjectItemCaseSensitive(metaJson, META_TIMESTAMP.c_str()); - if (timeStampObj == nullptr || !IsInt64(metaJson, META_TIMESTAMP)) { - cJSON_Delete(metaJson); - return false; + if (timeStampObj != nullptr && IsInt64(metaJson, META_TIMESTAMP)) { + pts_ = static_cast(timeStampObj->valueint); } - pts_ = static_cast(timeStampObj->valueint); - + cJSON *numberObj = cJSON_GetObjectItemCaseSensitive(metaJson, META_FRAME_NUMBER.c_str()); - if (numberObj == nullptr || !IsUInt32(metaJson, META_FRAME_NUMBER)) { - cJSON_Delete(metaJson); - return false; + if (numberObj != nullptr && IsUInt32(metaJson, META_FRAME_NUMBER)) { + frameNum_ = static_cast(numberObj->valueint); } - frameNum_ = static_cast(numberObj->valueint); cJSON *extTimeStampObj = cJSON_GetObjectItemCaseSensitive(metaJson, META_EXT_TIMESTAMP.c_str()); - if (extTimeStampObj == nullptr || !IsInt64(metaJson, META_EXT_TIMESTAMP)) { - cJSON_Delete(metaJson); - return false; + if (extTimeStampObj != nullptr && IsInt64(metaJson, META_EXT_TIMESTAMP)) { + extPts_ = static_cast(extTimeStampObj->valueint); } - extPts_ = static_cast(extTimeStampObj->valueint); cJSON *extNumberObj = cJSON_GetObjectItemCaseSensitive(metaJson, META_EXT_FRAME_NUMBER.c_str()); - if (extNumberObj == nullptr || !IsUInt32(metaJson, META_EXT_FRAME_NUMBER)) { - cJSON_Delete(metaJson); - return false; + if (extNumberObj != nullptr && IsUInt32(metaJson, META_EXT_FRAME_NUMBER)) { + extFrameNum_ = static_cast(extNumberObj->valueint); } - extFrameNum_ =static_cast(extNumberObj->valueint); cJSON_Delete(metaJson); return true; } diff --git a/av_transport/common/src/softbus_channel_adapter.cpp b/av_transport/common/src/softbus_channel_adapter.cpp index c94fa63e..5948281d 100644 --- a/av_transport/common/src/softbus_channel_adapter.cpp +++ b/av_transport/common/src/softbus_channel_adapter.cpp @@ -190,7 +190,7 @@ int32_t SoftbusChannelAdapter::CreateChannelServer(const std::string& pkgName, c } QosTV qos[] = { {.qos = QOS_TYPE_MIN_BW, .value = 40 * 1024 * 1024}, - {.qos = QOS_TYPE_MAX_LATENCY, .value = 8000}, + {.qos = QOS_TYPE_MAX_LATENCY, .value = 4000}, {.qos = QOS_TYPE_MIN_LATENCY, .value = 2000}, }; @@ -276,7 +276,7 @@ int32_t SoftbusChannelAdapter::OpenSoftbusChannel(const std::string &mySessName, QosTV qos[] = { {.qos = QOS_TYPE_MIN_BW, .value = 40 * 1024 * 1024}, - {.qos = QOS_TYPE_MAX_LATENCY, .value = 8000}, + {.qos = QOS_TYPE_MAX_LATENCY, .value = 4000}, {.qos = QOS_TYPE_MIN_LATENCY, .value = 2000}, }; -- Gitee From d8531c3ceebcaeb5f23240daeb4a569eaef56f15 Mon Sep 17 00:00:00 2001 From: wangyupan Date: Sat, 13 Jul 2024 07:47:43 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20av?= =?UTF-8?q?=5Ftransport/av=5Ftrans=5Fcontrol=5Fcenter/test/fuzztest/onstre?= =?UTF-8?q?amreceived=5Ffuzzer/avtransOnSessionClosed=5Ffuzzer.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../avtransOnSessionClosed_fuzzer.h | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.h diff --git a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.h b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.h deleted file mode 100644 index 6e353295..00000000 --- a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#ifndef TEST_AVTRANSONSESSIONCLOSED_FUZZER_H -#define TEST_AVTRANSONSESSIONCLOSED_FUZZER_H - -#define FUZZ_PROJECT_NAME "avtransonsessionclosed_fuzzer.cpp" - -#endif \ No newline at end of file -- Gitee From 13e17ee56720af29a252c1dc62a9fa5b972e2a78 Mon Sep 17 00:00:00 2001 From: wangyupan Date: Sat, 13 Jul 2024 07:47:58 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20av?= =?UTF-8?q?=5Ftransport/av=5Ftrans=5Fcontrol=5Fcenter/test/fuzztest/onstre?= =?UTF-8?q?amreceived=5Ffuzzer/avtransOnSessionClosed=5Ffuzzer.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../avtransOnSessionClosed_fuzzer.cpp | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.cpp diff --git a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.cpp b/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.cpp deleted file mode 100644 index dc775aaf..00000000 --- a/av_transport/av_trans_control_center/test/fuzztest/onstreamreceived_fuzzer/avtransOnSessionClosed_fuzzer.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 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 "avtransonsessionclosed_fuzzer.h" - -#include -#include -#include -#include - -#include "softbus_channel_adapter.h" - -namespace OHOS { -namespace DistributedHardware { -void AVTransOnSessionClosedFuzzTest(const uint8_t *data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(int32_t))) { - return; - } - int32_t sessionId = *(reinterpret_cast(data)); - ShutdownReason reason = *(reinterpret_cast(data)); - - SoftbusChannelAdapter::GetInstance().OnSoftbusChannelClosed(sessionId, reason); -} -} // 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::AVTransOnSessionClosedFuzzTest(data, size); - return 0; -} \ No newline at end of file -- Gitee