From 6eefbdee67eeedc6ce7c72bbb9d3968e3be60781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=88=E7=9A=93=E6=9D=B0?= Date: Thu, 9 Jan 2025 16:12:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 师皓杰 --- .../hdi_service/audio/v1_0/BUILD.gn | 28 +++++++++++++ .../hdi_service/audio_ext/v1_0/BUILD.gn | 30 ++++++++++++++ distributed_audio/hdi_service/common/BUILD.gn | 14 +++++++ distributed_camera/hdi_service/BUILD.gn | 41 +++++++++++++++++++ .../hdi_service/src/utils/dcamera.cpp | 5 ++- 5 files changed, 116 insertions(+), 2 deletions(-) diff --git a/distributed_audio/hdi_service/audio/v1_0/BUILD.gn b/distributed_audio/hdi_service/audio/v1_0/BUILD.gn index 5712458c4..c16850978 100644 --- a/distributed_audio/hdi_service/audio/v1_0/BUILD.gn +++ b/distributed_audio/hdi_service/audio/v1_0/BUILD.gn @@ -15,6 +15,14 @@ import("//build/ohos.gni") import("../../../distributedaudio.gni") ohos_shared_library("libaudio_manager_daudio_primary_service_1.0") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } include_dirs = [ "${hdf_ser_aud_path}/include", "${hdf_service_path}/hdi_service/common/include", @@ -31,6 +39,12 @@ ohos_shared_library("libaudio_manager_daudio_primary_service_1.0") { "./src/audio_render_interface_impl.cpp", ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + public_deps = [ "${hdf_service_path}/hdi_service/common:libdaudio_hdf_utils" ] external_deps = [ @@ -67,10 +81,24 @@ ohos_shared_library("libaudio_manager_daudio_primary_service_1.0") { } ohos_shared_library("libdaudio_primary_driver") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } include_dirs = [ "${hdf_ser_aud_path}/include" ] sources = [ "./src/audio_driver.cpp" ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] external_deps = [ diff --git a/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn b/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn index 677409697..e1edf8e8b 100644 --- a/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn +++ b/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn @@ -15,6 +15,15 @@ import("//build/ohos.gni") import("../../../distributedaudio.gni") ohos_shared_library("libdaudio_manager_daudio_ext_service_2.0") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } + include_dirs = [ "${hdf_ser_aud_ext_path}/include", "${hdf_ser_aud_path}/include", @@ -30,6 +39,12 @@ ohos_shared_library("libdaudio_manager_daudio_ext_service_2.0") { "${hdf_service_path}/hdi_service/common:libdaudio_hdf_utils", ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + external_deps = [ "cJSON:cjson", "c_utils:utils", @@ -52,10 +67,25 @@ ohos_shared_library("libdaudio_manager_daudio_ext_service_2.0") { } ohos_shared_library("libdaudio_ext_driver") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } + include_dirs = [ "${hdf_ser_aud_ext_path}/include" ] sources = [ "./src/daudio_manager_driver.cpp" ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + deps = [ "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_2.0" ] external_deps = [ diff --git a/distributed_audio/hdi_service/common/BUILD.gn b/distributed_audio/hdi_service/common/BUILD.gn index 77f972e0b..6088be183 100644 --- a/distributed_audio/hdi_service/common/BUILD.gn +++ b/distributed_audio/hdi_service/common/BUILD.gn @@ -14,6 +14,14 @@ import("//build/ohos.gni") ohos_shared_library("libdaudio_hdf_utils") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } include_dirs = [ "include", "log/include", @@ -25,6 +33,12 @@ ohos_shared_library("libdaudio_hdf_utils") { "utils/src/daudio_utils.cpp", ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + external_deps = [ "cJSON:cjson", "c_utils:utils", diff --git a/distributed_camera/hdi_service/BUILD.gn b/distributed_camera/hdi_service/BUILD.gn index 1dfa4b57e..606b06070 100644 --- a/distributed_camera/hdi_service/BUILD.gn +++ b/distributed_camera/hdi_service/BUILD.gn @@ -15,11 +15,25 @@ import("//build/ohos.gni") import("//drivers/peripheral/distributed_camera/distributedcamera.gni") ohos_shared_library("libdistributed_camera_provider_config") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } include_dirs = [ "${distributedcamera_hdf_path}/hdi_service/include/dcamera_provider" ] sources = [ "./src/config/dcamera_provider_config.cpp" ] deps = [ "${distributedcamera_hdf_path}/hdi_service:libdistributed_camera_hdf_service_1.1" ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + external_deps = [ "cJSON:cjson", "c_utils:utils", @@ -41,6 +55,14 @@ ohos_shared_library("libdistributed_camera_provider_config") { } ohos_shared_library("libdistributed_camera_host_config") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } include_dirs = [ "${distributedcamera_hdf_path}/hdi_service/include/dcamera_device", "${distributedcamera_hdf_path}/hdi_service/include/dcamera_host", @@ -49,6 +71,11 @@ ohos_shared_library("libdistributed_camera_host_config") { ] sources = [ "./src/config/dcamera_host_config.cpp" ] deps = [ "${distributedcamera_hdf_path}/hdi_service:libdistributed_camera_hdf_service_1.1" ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] external_deps = [ "cJSON:cjson", "c_utils:utils", @@ -75,6 +102,14 @@ ohos_shared_library("libdistributed_camera_host_config") { } ohos_shared_library("libdistributed_camera_hdf_service_1.1") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } include_dirs = [ "include/dcamera_device", "include/dcamera_host", @@ -103,6 +138,12 @@ ohos_shared_library("libdistributed_camera_hdf_service_1.1") { "LOG_DOMAIN=0xD004150", ] + ldflags = [ + "-fpie", + "-Wl,-z,relro", + "-Wl,-z,now", + ] + external_deps = [ "cJSON:cjson", "c_utils:utils", diff --git a/distributed_camera/hdi_service/src/utils/dcamera.cpp b/distributed_camera/hdi_service/src/utils/dcamera.cpp index 33f85ba0c..237dc5c9d 100644 --- a/distributed_camera/hdi_service/src/utils/dcamera.cpp +++ b/distributed_camera/hdi_service/src/utils/dcamera.cpp @@ -85,11 +85,12 @@ std::string Base64Encode(const unsigned char *toEncode, unsigned int len) DHLOGE("toEncode is null or len is zero."); return ret; } + int32_t length = static_cast(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; @@ -105,7 +106,7 @@ std::string Base64Encode(const unsigned char *toEncode, unsigned int len) } } - if (i) { + if (i > 0) { uint32_t j = 0; for (j = i; j < sizeof(charArray3); j++) { charArray3[j] = '\0'; -- Gitee