mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-24 01:09:51 +00:00
!7803 Anonymous print modification and lock-free access to linked list resources
Merge pull request !7803 from Zhangzi/master
This commit is contained in:
commit
2714e87a8a
@ -274,6 +274,17 @@ static SoftBusPermissionEntry *ProcessPermissionEntry(cJSON *object)
|
||||
return permissionEntry;
|
||||
}
|
||||
|
||||
static void PrintAnonymousMessage(const char *src, const char *dest)
|
||||
{
|
||||
char *tmpSrc = NULL;
|
||||
char *tmpDest = NULL;
|
||||
Anonymize(src, &tmpSrc);
|
||||
Anonymize(dest, &tmpDest);
|
||||
COMM_LOGD(COMM_PERM, "src=%{public}s, dest=%{public}s", AnonymizeWrapper(tmpSrc), AnonymizeWrapper(tmpDest));
|
||||
AnonymizeFree(tmpSrc);
|
||||
AnonymizeFree(tmpDest);
|
||||
}
|
||||
|
||||
int32_t CompareString(const char *src, const char *dest, bool regexp)
|
||||
{
|
||||
if (src == NULL || dest == NULL) {
|
||||
@ -286,14 +297,14 @@ int32_t CompareString(const char *src, const char *dest, bool regexp)
|
||||
return SOFTBUS_PERMISSION_DENIED;
|
||||
}
|
||||
if (regexec(®Comp, dest, 0, NULL, 0) == 0) {
|
||||
COMM_LOGD(COMM_PERM, "src=%{public}s, dest=%{public}s", src, dest);
|
||||
PrintAnonymousMessage(src, dest);
|
||||
regfree(®Comp);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
regfree(®Comp);
|
||||
} else {
|
||||
if (strcmp(src, dest) == 0) {
|
||||
COMM_LOGD(COMM_PERM, "src=%{public}s, dest=%{public}s", src, dest);
|
||||
PrintAnonymousMessage(src, dest);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
}
|
||||
@ -617,7 +628,10 @@ bool PermIsSecLevelPublic(const char *sessionName)
|
||||
}
|
||||
}
|
||||
(void)SoftBusMutexUnlock(&g_permissionEntryList->lock);
|
||||
COMM_LOGD(COMM_PERM, "PermIsSecLevelPublic: sessionName=%{public}s, ret=%{public}d", sessionName, ret);
|
||||
char *tmpName = NULL;
|
||||
Anonymize(sessionName, &tmpName);
|
||||
COMM_LOGD(COMM_PERM, "sessionName=%{public}s, ret=%{public}d", AnonymizeWrapper(tmpName), ret);
|
||||
AnonymizeFree(tmpName);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -649,7 +663,11 @@ static int32_t NewDynamicPermissionEntry(SoftBusPermissionEntry *permissionEntry
|
||||
|
||||
size_t length = strlen(sessionName);
|
||||
if (length >= SESSION_NAME_SIZE_MAX) {
|
||||
COMM_LOGE(COMM_PERM, "the length is too long. length=%{public}zd, sessionName=%{public}s", length, sessionName);
|
||||
char *tmpName = NULL;
|
||||
Anonymize(sessionName, &tmpName);
|
||||
COMM_LOGE(COMM_PERM, "the length is too long. length=%{public}zd, sessionName=%{public}s",
|
||||
length, AnonymizeWrapper(tmpName));
|
||||
AnonymizeFree(tmpName);
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (strcpy_s(permissionEntry->sessionName, SESSION_NAME_SIZE_MAX, sessionName) != EOK) {
|
||||
@ -716,7 +734,10 @@ int32_t AddDynamicPermission(int32_t callingUid, int32_t callingPid, const char
|
||||
g_dynamicPermissionList->cnt++;
|
||||
SoftBusMutexUnlock(&g_dynamicPermissionList->lock);
|
||||
|
||||
COMM_LOGD(COMM_PERM, "session dynamic permission granted. sessionName=%{public}s", sessionName);
|
||||
char *tmpName = NULL;
|
||||
Anonymize(sessionName, &tmpName);
|
||||
COMM_LOGD(COMM_PERM, "session dynamic permission granted. sessionName=%{public}s", AnonymizeWrapper(tmpName));
|
||||
AnonymizeFree(tmpName);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
@ -735,7 +756,11 @@ int32_t DeleteDynamicPermission(const char *sessionName)
|
||||
SoftBusFree(pe);
|
||||
g_dynamicPermissionList->cnt--;
|
||||
SoftBusMutexUnlock(&g_dynamicPermissionList->lock);
|
||||
COMM_LOGI(COMM_PERM, "session dynamic permission deleted. sessionName=%{public}s", sessionName);
|
||||
char *tmpName = NULL;
|
||||
Anonymize(sessionName, &tmpName);
|
||||
COMM_LOGI(COMM_PERM, "session dynamic permission deleted. sessionName=%{public}s",
|
||||
AnonymizeWrapper(tmpName));
|
||||
AnonymizeFree(tmpName);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -408,11 +408,12 @@ int32_t TransAddTcpChannelInfo(TcpChannelInfo *info)
|
||||
TRANS_LOGE(TRANS_CTRL, "lock error.");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
int32_t channelId = info->channelId;
|
||||
ListInit(&info->node);
|
||||
ListAdd(&g_tcpChannelInfoList->list, &(info->node));
|
||||
g_tcpChannelInfoList->cnt++;
|
||||
(void)SoftBusMutexUnlock(&g_tcpChannelInfoList->lock);
|
||||
TRANS_LOGI(TRANS_CTRL, "TcpChannelInfo add success, channelId=%{public}d.", info->channelId);
|
||||
TRANS_LOGI(TRANS_CTRL, "TcpChannelInfo add success, channelId=%{public}d.", channelId);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
|
@ -180,14 +180,14 @@ int32_t TransAddUdpChannel(UdpChannelInfo *channel)
|
||||
return SOFTBUS_TRANS_UDP_CHANNEL_ALREADY_EXIST;
|
||||
}
|
||||
}
|
||||
int64_t channelId = channel->info.myData.channelId;
|
||||
ListInit(&(channel->node));
|
||||
ListAdd(&(g_udpChannelMgr->list), &(channel->node));
|
||||
TRANS_LOGI(TRANS_CTRL, "add channelId=%{public}" PRId64, channel->info.myData.channelId);
|
||||
TRANS_LOGI(TRANS_CTRL, "add channelId=%{public}" PRId64, channelId);
|
||||
g_udpChannelMgr->cnt++;
|
||||
|
||||
(void)SoftBusMutexUnlock(&(g_udpChannelMgr->lock));
|
||||
TRANS_LOGI(TRANS_CTRL, "add udp channel success. channelId=%{public}" PRId64,
|
||||
channel->info.myData.channelId);
|
||||
TRANS_LOGI(TRANS_CTRL, "add udp channel success. channelId=%{public}" PRId64, channelId);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
|
@ -399,9 +399,13 @@ int32_t ClientAddSessionServer(SoftBusSecType type, const char *pkgName, const c
|
||||
|
||||
UnlockClientSessionServerList();
|
||||
char *tmpName = NULL;
|
||||
Anonymize(server->sessionName, &tmpName);
|
||||
TRANS_LOGI(TRANS_SDK, "sessionName=%{public}s, pkgName=%{public}s", tmpName, server->pkgName);
|
||||
char *tmpPkgName = NULL;
|
||||
Anonymize(pkgName, &tmpPkgName);
|
||||
Anonymize(sessionName, &tmpName);
|
||||
TRANS_LOGI(TRANS_SDK, "sessionName=%{public}s, pkgName=%{public}s",
|
||||
AnonymizeWrapper(tmpName), AnonymizeWrapper(tmpPkgName));
|
||||
AnonymizeFree(tmpName);
|
||||
AnonymizeFree(tmpPkgName);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,10 @@ void TransDeleteFileListener(const char *sessionName)
|
||||
LIST_FOR_EACH_ENTRY(fileNode, &(g_fileListener->list), FileListener, node) {
|
||||
if (strcmp(fileNode->mySessionName, sessionName) == 0) {
|
||||
ListDelete(&fileNode->node);
|
||||
TRANS_LOGI(TRANS_FILE, "delete sessionName = %{public}s", sessionName);
|
||||
char *tmpName = NULL;
|
||||
Anonymize(sessionName, &tmpName);
|
||||
TRANS_LOGI(TRANS_FILE, "delete sessionName=%{public}s", AnonymizeWrapper(tmpName));
|
||||
AnonymizeFree(tmpName);
|
||||
SoftBusFree(fileNode);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user