From e0d799f5009fe7cd59651327aa3b53a8d0b9d798 Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Thu, 26 May 2022 09:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=B1=E9=99=A9=E5=87=BD?= =?UTF-8?q?=E6=95=B0=20Signed-off-by:=20renguang1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unittest/UTTest_softbus_connector.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index 03ef0babb..01b7976d2 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -66,7 +66,7 @@ HWTEST_F(SoftbusConnectorTest, DeviceOnLine_001, testing::ext::TestSize.Level0) { std::string pkgName = "123"; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); deviceStateMgr->RegisterSoftbusStateCallback(); DeviceOnLine(SoftbusConnector::stateCallbackMap_, info); bool ret = false; @@ -88,7 +88,7 @@ HWTEST_F(SoftbusConnectorTest, DeviceOnLine_002, testing::ext::TestSize.Level0) { std::string pkgName = "123"; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); DeviceOnLine(SoftbusConnector::stateCallbackMap_, info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { @@ -109,7 +109,7 @@ HWTEST_F(SoftbusConnectorTest, DeviceOffLine_001, testing::ext::TestSize.Level0) { std::string pkgName = "123"; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); deviceStateMgr->RegisterSoftbusStateCallback(); DeviceOffLine(SoftbusConnector::stateCallbackMap_, info); bool ret = false; @@ -131,7 +131,7 @@ HWTEST_F(SoftbusConnectorTest, DeviceOffLine_002, testing::ext::TestSize.Level0) { std::string pkgName = "123"; DmDeviceInfo info; - strncpy(info.deviceId, "123", sizeof(info.deviceId)); + strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); DeviceOffLine(SoftbusConnector::stateCallbackMap_, info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { @@ -346,8 +346,8 @@ HWTEST_F(SoftbusConnectorTest, IsDeviceOnLine_001, testing::ext::TestSize.Level0 HWTEST_F(SoftbusConnectorTest, IsDeviceOnLine_002, testing::ext::TestSize.Level0) { std::string deviceId = "145677"; - NodeBasicInfo Info; - strncpy(Info.networkId, "145677", sizeof(Info.networkId)); + NodeBasicInfo info; + strcpy_s(info.networkId, DM_MAX_DEVICE_ID_LEN, "145677"); bool ret = softbusConnector->IsDeviceOnLine(deviceId); EXPECT_EQ(ret, false); } -- Gitee