!312 InterfaceToken校验

Merge pull request !312 from wuqi/master
This commit is contained in:
openharmony_ci
2022-03-07 13:49:52 +00:00
committed by Gitee
4 changed files with 17 additions and 0 deletions
+1
View File
@@ -73,6 +73,7 @@ enum {
DM_IPC_SEND_REQUEST_FAILED,
DM_IPC_NOT_REGISTER_FUNC,
DM_IPC_RESPOND_ERROR,
DM_IPC_WRITE_TOKEN_ERROR,
DM_DISCOVERY_REPEATED,
DM_AUTH_NOT_SUPPORT,
DM_AUTH_BUSINESS_BUSY,
@@ -33,6 +33,10 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr<IpcReq> r
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LOGE("WriteInterfaceToken fail!");
return DM_IPC_WRITE_TOKEN_ERROR;
}
if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) {
return DM_IPC_SEND_REQUEST_FAILED;
}
@@ -26,6 +26,12 @@ namespace DistributedHardware {
int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
LOGI("code = %d, flags= %d.", code, option.GetFlags());
auto remoteDescriptor = data.ReadInterfaceToken();
if (GetDescriptor() != remoteDescriptor) {
LOGI("ReadInterfaceToken fail!");
return ERR_INVALID_STATE;
}
if (IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply) == DM_OK) {
LOGE("on ipc cmd success");
return DM_OK;
@@ -81,6 +81,12 @@ void IpcServerStub::OnStop()
int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
LOGI("code = %d, flags= %d.", code, option.GetFlags());
auto remoteDescriptor = data.ReadInterfaceToken();
if (GetDescriptor() != remoteDescriptor) {
LOGI("ReadInterfaceToken fail!");
return ERR_INVALID_STATE;
}
int32_t ret = DM_OK;
ret = IpcCmdRegister::GetInstance().OnIpcCmd((int32_t)code, data, reply);
if (ret == DM_IPC_NOT_REGISTER_FUNC) {