!5021 fix:modify lnn distribute udidhash check

Merge pull request !5021 from 房冬/master
This commit is contained in:
openharmony_ci 2024-01-17 08:03:10 +00:00 committed by Gitee
commit 7ca898c0c8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 14 additions and 12 deletions

View File

@ -80,7 +80,7 @@ int32_t LnnGetNodeKeyInfoLen(int32_t key);
int32_t LnnGetNetworkIdByUuid(const char *uuid, char *buf, uint32_t len);
int32_t LnnGetNetworkIdByUdid(const char *udid, char *buf, uint32_t len);
int32_t LnnGetNetworkIdByBtMac(const char *btMac, char *buf, uint32_t len);
int32_t LnnGetNetworkIdByUdidHash(const char *udidHash, char *buf, uint32_t len);
int32_t LnnGetNetworkIdByUdidHash(const uint8_t *udidHash, uint32_t udidHashLen, char *buf, uint32_t len);
int32_t LnnGetConnSubFeatureByUdidHashStr(const char *udidHashStr, uint64_t *connSubFeature);
int32_t LnnSetLocalUnifiedName(const char *unifiedName);
bool LnnIsMasterNode(void);

View File

@ -2472,9 +2472,9 @@ int32_t LnnGetNetworkIdByBtMac(const char *btMac, char *buf, uint32_t len)
return SOFTBUS_NOT_FIND;
}
int32_t LnnGetNetworkIdByUdidHash(const char *udidHash, char *buf, uint32_t len)
int32_t LnnGetNetworkIdByUdidHash(const uint8_t *udidHash, uint32_t udidHashLen, char *buf, uint32_t len)
{
if (udidHash == NULL || udidHash[0] == '\0' || buf == NULL) {
if (udidHash == NULL || buf == NULL || udidHashLen == 0) {
LNN_LOGE(LNN_LEDGER, "udidHash is empty");
return SOFTBUS_INVALID_PARAM;
}

View File

@ -73,9 +73,10 @@ int32_t LnnGetNetworkIdByBtMac(const char *btMac, char *buf, uint32_t len)
return SOFTBUS_NOT_IMPLEMENT;
}
int32_t LnnGetNetworkIdByUdidHash(const char *udidHash, char *buf, uint32_t len)
int32_t LnnGetNetworkIdByUdidHash(const uint8_t *udidHash, uint32_t udidHashLen, char *buf, uint32_t len)
{
(void)udidHash;
(void)udidHashLen;
(void)buf;
(void)len;
return SOFTBUS_NOT_IMPLEMENT;

View File

@ -94,10 +94,10 @@ static int32_t GetRemoteUdidByBtMac(const char *peerMac, char *udid, int32_t len
return SOFTBUS_OK;
}
static int32_t GetRemoteBtMacByUdidHash(const char *udidHash, char *brMac, int32_t len)
static int32_t GetRemoteBtMacByUdidHash(const uint8_t *udidHash, uint32_t udidHashLen, char *brMac, int32_t len)
{
char networkId[NETWORK_ID_BUF_LEN] = {0};
if (LnnGetNetworkIdByUdidHash(udidHash, networkId, sizeof(networkId)) != SOFTBUS_OK) {
if (LnnGetNetworkIdByUdidHash(udidHash, udidHashLen, networkId, sizeof(networkId)) != SOFTBUS_OK) {
TRANS_LOGE(TRANS_CTRL, "LnnGetNetworkIdByUdidHash fail");
return SOFTBUS_NOT_FIND;
}
@ -170,7 +170,8 @@ static int32_t ConvertBrConnInfo2BleConnInfo(AuthConnInfo *connInfo)
static int32_t ConvertBleConnInfo2BrConnInfo(AuthConnInfo *connInfo)
{
char brMac[BT_MAC_LEN] = {0};
if (GetRemoteBtMacByUdidHash((char*)connInfo->info.bleInfo.deviceIdHash, brMac, BT_MAC_LEN) != SOFTBUS_OK) {
if (GetRemoteBtMacByUdidHash(connInfo->info.bleInfo.deviceIdHash, UDID_HASH_LEN,
brMac, BT_MAC_LEN) != SOFTBUS_OK) {
TRANS_LOGE(TRANS_CTRL, "get btmac by udid fail");
return SOFTBUS_ERR;
}

View File

@ -738,12 +738,12 @@ HWTEST_F(LNNDisctributedLedgerTest, LNN_ISLSA_NODE_Test_001, TestSize.Level1)
HWTEST_F(LNNDisctributedLedgerTest, LNN_GETNETWORKID_BYUDIDHASH_Test_001, TestSize.Level1)
{
const char *udidHash = "softBus";
uint8_t udidHash[UDID_HASH_LEN] = {0};
char buf = '0';
uint32_t len = 0;
int32_t ret = LnnGetNetworkIdByUdidHash(nullptr, nullptr, len);
int32_t ret = LnnGetNetworkIdByUdidHash(nullptr, len, nullptr, len);
EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
ret = LnnGetNetworkIdByUdidHash(udidHash, &buf, len);
ret = LnnGetNetworkIdByUdidHash(udidHash, UDID_HASH_LEN, &buf, len);
EXPECT_TRUE(ret != SOFTBUS_OK);
}

View File

@ -909,8 +909,8 @@ HWTEST_F(SoftbusProxyChannelMessageTest, TransProxyGetRemoteTest001, TestSize.Le
int32_t ret = GetRemoteUdidByBtMac(brMac, udid, UDID_BUF_LEN);
EXPECT_NE(SOFTBUS_OK, ret);
char deviceIdHash[UDID_HASH_LEN] = {0};
ret = GetRemoteBtMacByUdidHash(deviceIdHash, brMac, BT_MAC_LEN);
uint8_t deviceIdHash[UDID_HASH_LEN] = {0};
ret = GetRemoteBtMacByUdidHash(deviceIdHash, UDID_HASH_LEN, brMac, BT_MAC_LEN);
EXPECT_NE(SOFTBUS_OK, ret);
}