diff --git a/frameworks/native/src/service_proxy.cpp b/frameworks/native/src/service_proxy.cpp index 4b997cc71a9ac4fd48f9234f284d1a385f305aff..c596fc30c70ac0592af48724801afd2aeaa9cb75 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 a4444e9380534a7b002c325d3535e63f43d2fc6a..96274358326bbc3fbb6dfab715db75bb73ff425e 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)) {