fix code revice and check ptr

Signed-off-by: shenjiahao5 <shenjiahao5@huawei.com>
This commit is contained in:
shenjiahao5 2024-10-12 10:26:34 +08:00
parent b22a55e22e
commit a53480af71
3 changed files with 7 additions and 1 deletions

View File

@ -571,7 +571,8 @@ int64_t GetActiveAuthIdByConnInfo(const AuthConnInfo *connInfo, bool judgeTimeOu
auth[i] = NULL;
continue;
}
if ((currentTime - auth[i]->lastActiveTime >= MAX_AUTH_VALID_PERIOD) && judgeTimeOut) {
if (judgeTimeOut && (currentTime > auth[i]->lastActiveTime)
&& (currentTime - auth[i]->lastActiveTime >= MAX_AUTH_VALID_PERIOD)) {
AUTH_LOGI(AUTH_CONN, "auth manager timeout. authId=%{public}" PRId64, auth[i]->authId);
auth[i] = NULL;
}

View File

@ -346,6 +346,10 @@ static int32_t GetEnhancedP2pAuthKey(const char *udidHash, AuthSessionInfo *info
return SOFTBUS_ERR;
}
AuthManager *auth = GetAuthManagerByAuthId(authHandle.authId);
if (auth == NULL) {
AUTH_LOGE(AUTH_FSM, "get AuthManager fail");
return SOFTBUS_AUTH_NOT_FOUND;
}
int32_t index;
SessionKey sessionKey;
(void)memset_s(&sessionKey, sizeof(SessionKey), 0, sizeof(SessionKey));

View File

@ -74,6 +74,7 @@ static void UpdateDeviceNameInfo(const char *udid, const char *oldDeviceName)
NodeBasicInfo basic;
if (memset_s(&basic, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo)) != EOK) {
LNN_LOGE(LNN_LEDGER, "memset_s basic fail!");
return;
}
if (LnnGetBasicInfoByUdid(udid, &basic) != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "GetBasicInfoByUdid fail.");