diff --git a/common/BUILD.gn b/common/BUILD.gn index 76ba561aca177805ec7f016262ae018b8e84455a..591475def738b1fccc4e044bcf1988d5d536d02c 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 189954f37fba76a64d542d85e4681b362b9f6765..1ce1a1745fca9eb78120110a0508df8c4e08787d 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 654762c62e107ae16933222f1b8358fca5f1c706..6a59927900d3382dbe36f4aa54c316c2ad56c162 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 cee272f6e9c54b6361d7dd7bba79aff851b58e9f..d676ed0d963f7954c2abd63890e19d41a5a3e4ab 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 941df4463e2388007fbaa832bea7ca3c1ffa1825..7e17a0cac5e54c2b8c6b676b573e0e0f714c0950 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 eee491769eb8f8a600a70de05200d21b45c6f3cd..607632975b5c7f128b097d932f42b00c217e12c8 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 830602c16e29397a20d149250de471a40542ed6e..65e7dcebec52171e8531f6b1766181532149f510 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 09f33f1a15e78e43c00bcaa2284f94c5336eb8f3..3a4e289edf84bfacdfe5c1d3f49b9210977221db 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 066c224a6adce7963db26fcca508206b158a8db8..637c545c420c5069747ee2f7f124b4a6c6ce2c79 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 64f5fd084b89446f00ad69c208ac66d08ea07b88..a4a663010bdb3c668c7fca983a2e0b4ffaafa008 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",