From 784d17d44c8d59a4894bb57e3ecfe9dd7eb21fe7 Mon Sep 17 00:00:00 2001 From: liuxiaowei42 Date: Mon, 16 Oct 2023 19:08:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E9=9A=90=E7=A7=81=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit issue:https://gitee.com/openharmony/distributedhardware_distributed_camera/issues/I89FVE Signed-off-by: liuxiaowei42 --- common/BUILD.gn | 6 ++++++ common/src/utils/dcamera_utils_tools.cpp | 7 ++++++- interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn | 6 ++++++ interfaces/inner_kits/native_cpp/camera_source/BUILD.gn | 6 ++++++ services/cameraservice/cameraoperator/client/BUILD.gn | 6 ++++++ services/cameraservice/cameraoperator/handler/BUILD.gn | 6 ++++++ services/cameraservice/sinkservice/BUILD.gn | 6 ++++++ services/cameraservice/sourceservice/BUILD.gn | 6 ++++++ services/channel/BUILD.gn | 6 ++++++ services/data_process/BUILD.gn | 6 ++++++ 10 files changed, 60 insertions(+), 1 deletion(-) diff --git a/common/BUILD.gn b/common/BUILD.gn index 76ba561a..591475de 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -16,6 +16,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_utils") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "include/constants", "include/utils", diff --git a/common/src/utils/dcamera_utils_tools.cpp b/common/src/utils/dcamera_utils_tools.cpp index 189954f3..1ce1a174 100644 --- a/common/src/utils/dcamera_utils_tools.cpp +++ b/common/src/utils/dcamera_utils_tools.cpp @@ -79,11 +79,16 @@ int32_t GetAlignedHeight(int32_t width) std::string Base64Encode(const unsigned char *toEncode, unsigned int len) { std::string ret; + if (len < 0 || toEncode == nullptr || strlen(reinterpret_cast(toEncode)) != len) { + DHLOGE("toEncode is empty or len is zero"); + return ret; + } + int32_t length = len; uint32_t i = 0; unsigned char charArray3[3]; unsigned char charArray4[4]; - while (len--) { + while (length--) { charArray3[i++] = *(toEncode++); if (i == sizeof(charArray3)) { charArray4[INDEX_FIRST] = (charArray3[INDEX_FIRST] & PARAM_FC) >> OFFSET2; diff --git a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn index 654762c6..6a599279 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn @@ -16,6 +16,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_sink_sdk") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "${fwk_common_path}/utils/include" ] include_dirs += [ diff --git a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn index cee272f6..d676ed0d 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -16,6 +16,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_source_sdk") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "${fwk_common_path}/utils/include" ] include_dirs += [ diff --git a/services/cameraservice/cameraoperator/client/BUILD.gn b/services/cameraservice/cameraoperator/client/BUILD.gn index 941df446..7e17a0ca 100644 --- a/services/cameraservice/cameraoperator/client/BUILD.gn +++ b/services/cameraservice/cameraoperator/client/BUILD.gn @@ -17,6 +17,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_client") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "${graphicstandard_path}/frameworks/surface/include", "${camerastandard_path}/interfaces/inner_api/native/camera/include", diff --git a/services/cameraservice/cameraoperator/handler/BUILD.gn b/services/cameraservice/cameraoperator/handler/BUILD.gn index eee49176..60763297 100644 --- a/services/cameraservice/cameraoperator/handler/BUILD.gn +++ b/services/cameraservice/cameraoperator/handler/BUILD.gn @@ -17,6 +17,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_handler") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "//third_party/cJSON", "//third_party/jsoncpp/include", diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 830602c1..65e7dceb 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -17,6 +17,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_sink") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "${av_transport_path}/common/include", "${graphicstandard_path}/frameworks/surface/include", diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 09f33f1a..3a4e289e 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -17,6 +17,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_source") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "${av_transport_path}/common/include", "${fwk_common_path}/utils/include", diff --git a/services/channel/BUILD.gn b/services/channel/BUILD.gn index 066c224a..637c545c 100644 --- a/services/channel/BUILD.gn +++ b/services/channel/BUILD.gn @@ -17,6 +17,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_channel") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "${av_transport_path}/common/include", "${fwk_common_path}/utils/include", diff --git a/services/data_process/BUILD.gn b/services/data_process/BUILD.gn index 64f5fd08..a4a66301 100644 --- a/services/data_process/BUILD.gn +++ b/services/data_process/BUILD.gn @@ -17,6 +17,12 @@ import( "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") ohos_shared_library("distributed_camera_data_process") { + sanitize = { + boundary_sanitize = true + integer_overflow = true + ubsan = true + } + stack_protector_ret = true include_dirs = [ "${fwk_common_path}/utils/include", "${fwk_utils_path}/include/eventbus", -- Gitee