From a575c3803bbe8a5a633082a3472003c651c8d769 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Fri, 23 Aug 2024 08:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9=E5=9B=9E?= =?UTF-8?q?=E5=90=885.0-Release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- common/include/constants_dinput.h | 3 ++- common/include/input_hub.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/include/constants_dinput.h b/common/include/constants_dinput.h index 6979e83..d33bffe 100644 --- a/common/include/constants_dinput.h +++ b/common/include/constants_dinput.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -48,6 +48,7 @@ namespace DistributedInput { const uint32_t SCREEN_MSG_MAX = 40 * 1024 * 1024; const uint32_t AUTH_SESSION_SIDE_SERVER = 0; const uint32_t IPC_VECTOR_MAX_SIZE = 32; + const uint32_t EVENT_BUFFER_MAX = 512; /* * Device Type definitions diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index 77ee319..55704f9 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -1071,7 +1071,7 @@ int32_t InputHub::UnregisterFdFromEpoll(int fd) const int32_t InputHub::ReadNotifyLocked() { size_t res; - char eventBuf[512]; + char eventBuf[EVENT_BUFFER_MAX] = {0}; struct inotify_event *event; DHLOGI("readNotify nfd: %{public}d\n", iNotifyFd_); @@ -1087,7 +1087,7 @@ int32_t InputHub::ReadNotifyLocked() { size_t eventSize = 0; size_t eventPos = 0; - while (res >= sizeof(*event)) { + while (res >= sizeof(*event) && eventPos < static_cast(EVENT_BUFFER_MAX)) { event = reinterpret_cast(eventBuf + eventPos); JudgeDeviceOpenOrClose(*event); eventSize = sizeof(*event) + event->len; -- Gitee