diff --git a/OAT.xml b/OAT.xml
index 7cc66e0dbebe672d20e40dbc04b527cdc53c2dc0..c5ccef508a45ab94f444a3ed0d69cc2435227b9c 100755
--- a/OAT.xml
+++ b/OAT.xml
@@ -33,7 +33,6 @@
-
@@ -43,10 +42,6 @@
-
-
-
-
diff --git a/bundle.json b/bundle.json
index f1ff2dadd5f624ede2226bc80cdca2fe6092c438..f3ffe280a01a343a19116b42f65e5ca0faf94e70 100644
--- a/bundle.json
+++ b/bundle.json
@@ -27,7 +27,6 @@
"ability_base",
"ability_runtime",
"access_token",
- "bounds_checking_function",
"bundle_framework",
"common_event_service",
"c_utils",
@@ -39,7 +38,6 @@
"hitrace",
"ipc",
"init",
- "json",
"memmgr",
"napi",
"os_account",
diff --git a/frameworks/capi/BUILD.gn b/frameworks/capi/BUILD.gn
index de16e66a161ee312b8f3c9fdf4692984fde71293..3aa365bc34ac4704e87a2b6f4c28f9b9824b42b9 100644
--- a/frameworks/capi/BUILD.gn
+++ b/frameworks/capi/BUILD.gn
@@ -33,10 +33,7 @@ ohos_shared_library("ohvibrator") {
deps =
[ "$SUBSYSTEM_DIR/frameworks/native/vibrator:vibrator_interface_native" ]
- external_deps = [
- "c_utils:utils",
- "hilog:libhilog",
- ]
+ external_deps = [ "hilog:libhilog" ]
cflags_cc = [ "-fstack-protector-strong" ]
relative_install_dir = "ndk"
diff --git a/frameworks/capi/vibrator.cpp b/frameworks/capi/vibrator.cpp
index b62fb33c6580d15c05ac97b2a8fce44ab31fb9af..54328ee49f5016c6e58dae44462b0ddb5dfb9398 100644
--- a/frameworks/capi/vibrator.cpp
+++ b/frameworks/capi/vibrator.cpp
@@ -50,7 +50,7 @@ int32_t OH_Vibrator_PlayVibrationCustom(Vibrator_FileDescription fileDescription
{
if (!OHOS::Sensors::IsSupportVibratorCustom()) {
MISC_HILOGE("feature is not supported");
- return UNSUPPORTED;
+ return OHOS::Sensors::IS_NOT_SUPPORTED;
}
if ((fileDescription.fd < 0) || (fileDescription.offset < 0) || (fileDescription.length <= 0)) {
MISC_HILOGE("fileDescription is invalid");
diff --git a/frameworks/js/ani/vibrator/include/ani_utils.h b/frameworks/js/ani/vibrator/include/ani_utils.h
index 663a794dbe6a1477a0f09e0c0bb4c60fd6fb9d3d..807c874bc937f7ec89bf44be3402efaabce6d8e9 100644
--- a/frameworks/js/ani/vibrator/include/ani_utils.h
+++ b/frameworks/js/ani/vibrator/include/ani_utils.h
@@ -176,7 +176,12 @@ bool UnionAccessor::TryConvertArray(std::vector &value)
std::cerr << "Object_GetPropertyByName_Double length failed" << std::endl;
return false;
}
- for (int i = 0; i < int(length); i++) {
+ int64_t lengthValue = static_cast(length);
+ if (lengthValue < 0 || lengthValue > INT64_MAX) {
+ std::cerr << "Invalid length" << std::endl;
+ return false;
+ }
+ for (int64_t i = 0; i < lengthValue; i++) {
ani_ref ref;
if (ANI_OK != env_->Object_CallMethodByName_Ref(obj_, "$_get", "I:Lstd/core/Object;", &ref, (ani_int)i)) {
std::cerr << "Object_GetPropertyByName_Ref failed" << std::endl;
@@ -200,7 +205,12 @@ bool UnionAccessor::TryConvertArray(std::vector &value)
std::cerr << "Object_GetPropertyByName_Double length failed" << std::endl;
return false;
}
- for (int i = 0; i < int(length); i++) {
+ int64_t lengthValue = static_cast(length);
+ if (lengthValue < 0 || lengthValue > INT64_MAX) {
+ std::cerr << "Invalid length" << std::endl;
+ return false;
+ }
+ for (int64_t i = 0; i < lengthValue; i++) {
ani_ref ref;
if (ANI_OK != env_->Object_CallMethodByName_Ref(obj_, "$_get", "I:Lstd/core/Object;", &ref, (ani_int)i)) {
std::cerr << "Object_GetPropertyByName_Ref failed" << std::endl;
@@ -224,7 +234,12 @@ bool UnionAccessor::TryConvertArray(std::vector &value)
std::cerr << "Object_GetPropertyByName_Double length failed" << std::endl;
return false;
}
- for (int i = 0; i < int(length); i++) {
+ int64_t lengthValue = static_cast(length);
+ if (lengthValue < 0 || lengthValue > INT64_MAX) {
+ std::cerr << "Invalid length" << std::endl;
+ return false;
+ }
+ for (int64_t i = 0; i < lengthValue; i++) {
ani_ref ref;
if (ANI_OK != env_->Object_CallMethodByName_Ref(obj_, "$_get", "I:Lstd/core/Object;", &ref, (ani_int)i)) {
std::cerr << "Object_GetPropertyByName_Ref failed" << std::endl;
@@ -270,8 +285,12 @@ bool UnionAccessor::TryConvertArray(std::vector &value
std::cerr << "Object_GetPropertyByName_Double length failed" << std::endl;
return false;
}
-
- for (int i = 0; i < int(length); i++) {
+ int64_t lengthValue = static_cast(length);
+ if (lengthValue < 0 || lengthValue > INT64_MAX) {
+ std::cerr << "Invalid length" << std::endl;
+ return false;
+ }
+ for (int64_t i = 0; i < lengthValue; i++) {
ani_ref ref;
if (ANI_OK != env_->Object_CallMethodByName_Ref(obj_, "$_get", "I:Lstd/core/Object;", &ref, (ani_int)i)) {
std::cerr << "Object_GetPropertyByName_Double length failed" << std::endl;
@@ -327,7 +346,10 @@ std::optional OptionalAccessor::Convert()
}
ani_size strSize;
- env_->String_GetUTF8Size(static_cast(obj_), &strSize);
+ auto status = env_->String_GetUTF8Size(static_cast(obj_), &strSize);
+ if (status != ANI_OK) {
+ return std::nullopt;
+ }
std::vector buffer(strSize + 1);
char* utf8_buffer = buffer.data();
diff --git a/frameworks/js/ani/vibrator/src/vibrator_ani.cpp b/frameworks/js/ani/vibrator/src/vibrator_ani.cpp
index 47870c33098854fe03690687479fb0e12832642a..3686e63eda2f2667bc205478bc549c1ee3876b76 100644
--- a/frameworks/js/ani/vibrator/src/vibrator_ani.cpp
+++ b/frameworks/js/ani/vibrator/src/vibrator_ani.cpp
@@ -22,7 +22,6 @@
#include