diff --git a/core/frame/standard/init/include/softbus_server_stub.h b/core/frame/standard/init/include/softbus_server_stub.h index 53546701d8dae9b561976efaaab53cc00fc60a38..c5ccad7434effa18265c5be0cd43e24c4205c605 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 d95228ecad60c8f44270f6ace17ea5a149e758fb..f6cacc320a80d4c1bbc3f069bcab828865d150d2 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]; @@ -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; @@ -405,6 +400,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)) {