From abb58c2f1859f8bb06f2955dd04a833df4c6d104 Mon Sep 17 00:00:00 2001 From: hhchinasoft Date: Wed, 9 Mar 2022 17:53:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSendFile=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A4=84=E7=90=86IPC=E5=A4=96=E9=83=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=97=B6=E5=8F=82=E5=8A=A0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hhchinasoft --- frameworks/native/src/service_proxy.cpp | 7 +++++++ .../src/ipc/distributedfile_service_stub.cpp | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/frameworks/native/src/service_proxy.cpp b/frameworks/native/src/service_proxy.cpp index 4b997cc71..c596fc30c 100644 --- a/frameworks/native/src/service_proxy.cpp +++ b/frameworks/native/src/service_proxy.cpp @@ -30,11 +30,18 @@ int32_t ServiceProxy::SendFile(const std::string &cid, } data.WriteString(cid); int32_t sourceListNumber = sourceFileList.size(); + if (sourceListNumber != 1) { + return DFS_PARAM_FILE_COUNT_ERROR; + } data.WriteInt32(sourceListNumber); for (int32_t index = 0; index < sourceListNumber; ++index) { data.WriteString(sourceFileList.at(index)); } + int32_t destinationListNumber = destinationFileList.size(); + if (destinationListNumber > 1) { + return DFS_PARAM_FILE_COUNT_ERROR; + } data.WriteInt32(destinationListNumber); for (int32_t index = 0; index < destinationListNumber; ++index) { data.WriteString(destinationFileList.at(index)); diff --git a/services/distributedfileservice/src/ipc/distributedfile_service_stub.cpp b/services/distributedfileservice/src/ipc/distributedfile_service_stub.cpp index a4444e938..962743583 100644 --- a/services/distributedfileservice/src/ipc/distributedfile_service_stub.cpp +++ b/services/distributedfileservice/src/ipc/distributedfile_service_stub.cpp @@ -70,16 +70,27 @@ int32_t DistributedFileServiceStub::SendFileStub(MessageParcel &data, MessagePar } int32_t sourceListNumber = data.ReadInt32(); + if (sourceListNumber != 1) { + return DFS_PARAM_FILE_COUNT_ERROR; + } std::vector srcList; for (int32_t index = 0; index < sourceListNumber; ++index) { srcList.push_back(data.ReadString()); } - std::vector dstList; + int32_t destinationListNumber = data.ReadInt32(); + if (destinationListNumber > 1) { + return DFS_PARAM_FILE_COUNT_ERROR; + } + std::vector dstList; for (int32_t index = 0; index < destinationListNumber; ++index) { dstList.push_back(data.ReadString()); } + uint32_t fileCount = data.ReadUint32(); + if (fileCount != 1) { + return DFS_PARAM_FILE_COUNT_ERROR; + } int32_t result = SendFile(cid, srcList, dstList, fileCount); if (!reply.WriteInt32(result)) { -- Gitee