From bb0aa093b10c7950dd41a2942561c0ced17ac74e Mon Sep 17 00:00:00 2001 From: zgit2021 Date: Thu, 26 May 2022 21:16:54 +0800 Subject: [PATCH 1/2] add permission check before send message Signed-off-by: zgit2021 Change-Id: I87f784b4ae184191818a58a4908afae2a047fa49 --- core/frame/standard/init/include/softbus_server_stub.h | 2 +- core/frame/standard/init/src/softbus_server_stub.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/frame/standard/init/include/softbus_server_stub.h b/core/frame/standard/init/include/softbus_server_stub.h index 53546701d8..c5ccad7434 100644 --- a/core/frame/standard/init/include/softbus_server_stub.h +++ b/core/frame/standard/init/include/softbus_server_stub.h @@ -43,7 +43,7 @@ private: int32_t CloseChannelInner(MessageParcel &data, MessageParcel &reply); int32_t SendMessageInner(MessageParcel &data, MessageParcel &reply); int32_t CheckOpenSessionPermission(const SessionParam *param); - int32_t CheckCloseChannelPermission(int32_t channelId, int32_t channelType); + int32_t CheckChannelPermission(int32_t channelId, int32_t channelType); int32_t JoinLNNInner(MessageParcel &data, MessageParcel &reply); int32_t LeaveLNNInner(MessageParcel &data, MessageParcel &reply); diff --git a/core/frame/standard/init/src/softbus_server_stub.cpp b/core/frame/standard/init/src/softbus_server_stub.cpp index d95228ecad..4dca6e04dc 100644 --- a/core/frame/standard/init/src/softbus_server_stub.cpp +++ b/core/frame/standard/init/src/softbus_server_stub.cpp @@ -53,7 +53,7 @@ int32_t SoftBusServerStub::CheckOpenSessionPermission(const SessionParam *param) return SOFTBUS_OK; } -int32_t SoftBusServerStub::CheckCloseChannelPermission(int32_t channelId, int32_t channelType) +int32_t SoftBusServerStub::CheckChannelPermission(int32_t channelId, int32_t channelType) { char pkgName[PKG_NAME_SIZE_MAX]; char sessionName[SESSION_NAME_SIZE_MAX]; @@ -405,6 +405,10 @@ int32_t SoftBusServerStub::SendMessageInner(MessageParcel &data, MessageParcel & SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "SendMessage message type failed!"); return SOFTBUS_ERR; } + if (CheckChannelPermission(channelId, channelType) != SOFTBUS_OK) { + SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "SendMessage permission check failed!"); + return SOFTBUS_PERMISSION_DENIED; + } int32_t retReply = SendMessage(channelId, channelType, dataInfo, len, msgType); if (!reply.WriteInt32(retReply)) { -- Gitee From c1466c90c4c73eb7cf5c27d88c586b0f09491858 Mon Sep 17 00:00:00 2001 From: defeng2020 Date: Tue, 1 Mar 2022 02:21:00 +0000 Subject: [PATCH 2/2] sync weekly Signed-off-by: wudefeng --- core/frame/standard/init/src/softbus_server_stub.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/core/frame/standard/init/src/softbus_server_stub.cpp b/core/frame/standard/init/src/softbus_server_stub.cpp index 4dca6e04dc..f6cacc320a 100644 --- a/core/frame/standard/init/src/softbus_server_stub.cpp +++ b/core/frame/standard/init/src/softbus_server_stub.cpp @@ -365,12 +365,7 @@ int32_t SoftBusServerStub::CloseChannelInner(MessageParcel &data, MessageParcel return SOFTBUS_ERR; } - int32_t retReply = CheckCloseChannelPermission(channelId, channelType); - if (retReply != SOFTBUS_OK) { - goto EXIT; - } - retReply = CloseChannel(channelId, channelType); -EXIT: + int32_t retReply = CloseChannel(channelId, channelType); if (!reply.WriteInt32(retReply)) { SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "CloseChannelInner write reply failed!"); return SOFTBUS_ERR; -- Gitee