diff --git a/common/BUILD.gn b/common/BUILD.gn index 52a0d330c43a9abe56f0d0c74126d99575dee3b7..82066840ca9c6343c185802d38eac95540bc376f 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -43,6 +43,8 @@ ohos_shared_library("distributed_device_profile_common") { boundary_sanitize = true integer_overflow = true ubsan = true + cfi = true + cfi_cross_dso = true debug = false } diff --git a/interfaces/innerkits/core/BUILD.gn b/interfaces/innerkits/core/BUILD.gn index 8af56923e0c8fb81a1cbb2fb4484ade24bd5287c..95a346e3e5f84d7191123cdada091e75d367e670 100644 --- a/interfaces/innerkits/core/BUILD.gn +++ b/interfaces/innerkits/core/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -46,6 +46,8 @@ ohos_shared_library("distributed_device_profile_sdk") { boundary_sanitize = true integer_overflow = true ubsan = true + cfi = true + cfi_cross_dso = true debug = false } diff --git a/radar/BUILD.gn b/radar/BUILD.gn index 26f585c95d344a70f51dc48d260d82242664594e..93fae8e1b45b1b20ba2715ae148025454340d1da 100644 --- a/radar/BUILD.gn +++ b/radar/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 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 @@ -16,6 +16,11 @@ import("//build/ohos_var.gni") import("//foundation/deviceprofile/device_info_manager/deviceprofile.gni") ohos_shared_library("device_profile_radar") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } ldflags = [ "-Wl,-z,relro", diff --git a/services/core/BUILD.gn b/services/core/BUILD.gn index 30b809608647bbe173df4a9c1715f189941f498d..abd0f5e719565f23383b67ab4cef65252350a81c 100644 --- a/services/core/BUILD.gn +++ b/services/core/BUILD.gn @@ -73,6 +73,8 @@ ohos_shared_library("distributed_device_profile_svr") { boundary_sanitize = true integer_overflow = true ubsan = true + cfi = true + cfi_cross_dso = true debug = false } diff --git a/services/core/test/unittest/device_profile_dao_test.cpp b/services/core/test/unittest/device_profile_dao_test.cpp index 2ff993a50326a25fdacbf4a2499016d5bdd5942a..fcd069a8dc1cbf50e433c1ef13520a4485d96aeb 100644 --- a/services/core/test/unittest/device_profile_dao_test.cpp +++ b/services/core/test/unittest/device_profile_dao_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -113,40 +113,15 @@ HWTEST_F(DeviceProfileDaoTest, PutDeviceProfile001, TestSize.Level1) { DeviceProfileDao::GetInstance().Init(); DeviceProfile deviceProfile; - int32_t result = DeviceProfileDao::GetInstance().PutDeviceProfile(deviceProfile); - EXPECT_EQ(result, DP_PUT_TRUST_DEVICE_PROFILE_FAIL); - DeviceProfileDao::GetInstance().UnInit(); -} - -/* - * @tc.name: PutDeviceProfile002 - * @tc.desc: PutDeviceProfile - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DeviceProfileDaoTest, PutDeviceProfile002, TestSize.Level1) -{ + DeviceProfileDao::GetInstance().PutDeviceProfile(deviceProfile); DeviceProfileDao::GetInstance().UnInit(); - DeviceProfile deviceProfile; int32_t result = DeviceProfileDao::GetInstance().PutDeviceProfile(deviceProfile); - EXPECT_EQ(result, DP_PUT_TRUST_DEVICE_PROFILE_FAIL); -} - -/* - * @tc.name: GetDeviceProfiles003 - * @tc.desc: GetDeviceProfiles - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DeviceProfileDaoTest, PutDeviceProfile003, TestSize.Level1) -{ DeviceProfileDao::GetInstance().Init(); - DeviceProfile deviceProfile; deviceProfile.SetDeviceId("deviceId"); deviceProfile.SetUserId(1); - int ret = DeviceProfileDao::GetInstance().PutDeviceProfile(deviceProfile); - EXPECT_EQ(ret, DP_PUT_TRUST_DEVICE_PROFILE_FAIL); + DeviceProfileDao::GetInstance().PutDeviceProfile(deviceProfile); DeviceProfileDao::GetInstance().UnInit(); + EXPECT_EQ(result, DP_PUT_TRUST_DEVICE_PROFILE_FAIL); } /*