From 1b69732a13737a4ff44aad67495341816dda6ef6 Mon Sep 17 00:00:00 2001 From: wangzhaohao Date: Fri, 6 Jun 2025 09:45:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=89=8D=E5=90=91CFI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzhaohao --- common/BUILD.gn | 2 ++ interfaces/innerkits/core/BUILD.gn | 2 ++ radar/BUILD.gn | 5 +++++ services/core/BUILD.gn | 2 ++ 4 files changed, 11 insertions(+) diff --git a/common/BUILD.gn b/common/BUILD.gn index 52a0d330..82066840 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 8af56923..ced16346 100644 --- a/interfaces/innerkits/core/BUILD.gn +++ b/interfaces/innerkits/core/BUILD.gn @@ -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 26f585c9..6d3fb937 100644 --- a/radar/BUILD.gn +++ b/radar/BUILD.gn @@ -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 30b80960..abd0f5e7 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 } -- Gitee From a67d14c5249d3f42a44fce5eb99ae9f21021fa77 Mon Sep 17 00:00:00 2001 From: wangzhaohao Date: Fri, 6 Jun 2025 16:24:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=89=8D=E5=90=91CFI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzhaohao --- interfaces/innerkits/core/BUILD.gn | 2 +- radar/BUILD.gn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/core/BUILD.gn b/interfaces/innerkits/core/BUILD.gn index ced16346..95a346e3 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 diff --git a/radar/BUILD.gn b/radar/BUILD.gn index 6d3fb937..93fae8e1 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 -- Gitee From 5977435e66a243f24e60a7865b9714f870e47b71 Mon Sep 17 00:00:00 2001 From: wzhhhh Date: Fri, 6 Jun 2025 08:26:43 +0000 Subject: [PATCH 3/3] fix UT Signed-off-by: wzhhhh --- .../test/unittest/device_profile_dao_test.cpp | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/services/core/test/unittest/device_profile_dao_test.cpp b/services/core/test/unittest/device_profile_dao_test.cpp index 2ff993a5..fcd069a8 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); } /* -- Gitee