From 46cfa87869405e74dba3be1728453a14c841f96f Mon Sep 17 00:00:00 2001 From: chyyy0213 Date: Fri, 22 Jul 2022 12:21:58 +0800 Subject: [PATCH] add vector protect for ipc TRANS_ID_GET_ANIMATION_CALLBACK Signed-off-by: chyyy0213 Change-Id: Iae70e5612e2060df132c8c3c117478fd2aaa93cf Signed-off-by: chyyy0213 --- wmserver/src/zidl/window_manager_proxy.cpp | 18 ++++-------------- wmserver/src/zidl/window_manager_stub.cpp | 5 +---- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/wmserver/src/zidl/window_manager_proxy.cpp b/wmserver/src/zidl/window_manager_proxy.cpp index 6aee5483..8c9f04b8 100644 --- a/wmserver/src/zidl/window_manager_proxy.cpp +++ b/wmserver/src/zidl/window_manager_proxy.cpp @@ -590,22 +590,12 @@ void WindowManagerProxy::MinimizeWindowsByLauncher(std::vector windowI WLOGFE("WriteInterfaceToken failed"); return; } - auto size = static_cast(windowIds.size()); - const uint32_t maxWindowNum = 100; - if (size > maxWindowNum) { - WLOGFE("windowNum cannot exceeds than 100"); + + if (!data.WriteUInt32Vector(windowIds)) { + WLOGFE("Write windowIds failed"); return; } - if (!data.WriteUint32(size)) { - WLOGFE("Write windowNum failed"); - return; - } - for (auto id : windowIds) { - if (!data.WriteUint32(id)) { - WLOGFE("Write windowId failed"); - return; - } - } + if (!data.WriteBool(isAnimated)) { WLOGFE("Write isAnimated failed"); return; diff --git a/wmserver/src/zidl/window_manager_stub.cpp b/wmserver/src/zidl/window_manager_stub.cpp index cee4a0e3..ba9832d4 100644 --- a/wmserver/src/zidl/window_manager_stub.cpp +++ b/wmserver/src/zidl/window_manager_stub.cpp @@ -201,10 +201,7 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M } case WindowManagerMessage::TRANS_ID_GET_ANIMATION_CALLBACK: { std::vector windowIds; - uint32_t windowNum = data.ReadUint32(); - for (uint32_t i = 0; i < windowNum; ++i) { - windowIds.push_back(data.ReadUint32()); - } + data.ReadUInt32Vector(&windowIds); bool isAnimated = data.ReadBool(); sptr finishedCallback = nullptr; MinimizeWindowsByLauncher(windowIds, isAnimated, finishedCallback);