diff --git a/frameworks/proxy/events/src/input_event.cpp b/frameworks/proxy/events/src/input_event.cpp index 309996b41d39c20812f0c236d839acc8de608259..fa7e3121b0dcd9463175908e8435c10fc8bc3648 100755 --- a/frameworks/proxy/events/src/input_event.cpp +++ b/frameworks/proxy/events/src/input_event.cpp @@ -49,7 +49,10 @@ void InputEvent::Reset() actionTime_ = 0; } id_ = -1; - actionTime_ = (ts.tv_sec * 1000000 + (ts.tv_nsec / 1000)); + if (!AddInt64(ts.tv_sec * 1000000, ts.tv_nsec / 1000, actionTime_)) { + MMI_HILOGE("The addition of actionTime_ overflows"); + return; + } action_ = ACTION_UNKNOWN; actionStartTime_ = actionTime_; deviceId_ = -1; diff --git a/service/timer_manager/src/timer_manager.cpp b/service/timer_manager/src/timer_manager.cpp index f0042d0d3120f02157833a531bb5ee8f74e8e201..d92d819b83725331682bc95c96c8f0a77a5dea21 100755 --- a/service/timer_manager/src/timer_manager.cpp +++ b/service/timer_manager/src/timer_manager.cpp @@ -23,6 +23,7 @@ constexpr int32_t MIN_INTERVAL = 50; constexpr int32_t MAX_INTERVAL = 4096; constexpr int32_t MAX_TIMER_COUNT = 32; constexpr int32_t NONEXISTENT_ID = -1; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "TimerManager" }; } // namespace int32_t TimerManager::AddTimer(int32_t intervalMs, int32_t repeatCount, std::function callback) @@ -91,7 +92,11 @@ int32_t TimerManager::AddTimerInternal(int32_t intervalMs, int32_t repeatCount, timer->intervalMs = intervalMs; timer->repeatCount = repeatCount; timer->callbackCount = 0; - timer->nextCallTime = GetMillisTime() + intervalMs; + auto nowTime = GetMillisTime(); + if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { + MMI_HILOGE("The addition of nextCallTime in TimerItem overflows"); + return NONEXISTENT_ID; + } timer->callback = callback; InsertTimerInternal(timer); return timerId; @@ -115,7 +120,10 @@ int32_t TimerManager::ResetTimerInternal(int32_t timerId) auto timer = std::move(*it); timers_.erase(it); auto nowTime = GetMillisTime(); - timer->nextCallTime = nowTime + timer->intervalMs; + if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { + MMI_HILOGE("The addition of nextCallTime in TimerItem overflows"); + return RET_ERR; + } timer->callbackCount = 0; InsertTimerInternal(timer); return RET_OK; @@ -181,7 +189,10 @@ void TimerManager::ProcessTimersInternal() curTimer->callback(); continue; } - curTimer->nextCallTime = nowTime + curTimer->intervalMs; + if (!AddInt64(nowTime, curTimer->intervalMs, curTimer->nextCallTime)) { + MMI_HILOGE("The addition of nextCallTime in TimerItem overflows"); + return; + } const auto& timer = InsertTimerInternal(curTimer); timer->callback(); } diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/input_windows_manager.cpp index 57ddd390e6d7231149efd157dcd660ccf621dc2e..e5c51fb2d6aaa3fc6baa90d78f4a093b4a896ae3 100755 --- a/service/window_manager/src/input_windows_manager.cpp +++ b/service/window_manager/src/input_windows_manager.cpp @@ -326,8 +326,18 @@ const DisplayGroupInfo& InputWindowsManager::GetDisplayGroupInfo() bool InputWindowsManager::IsInHotArea(int32_t x, int32_t y, const std::vector &rects) const { for (const auto &item : rects) { - if (((x >= item.x) && (x < (item.x + item.width))) && - (y >= item.y) && (y < (item.y + item.height))) { + int32_t displayMaxX = 0; + int32_t displayMaxY = 0; + if (!AddInt32(item.x, item.width, displayMaxX)) { + MMI_HILOGE("The addition of displayMaxX overflows"); + return false; + } + if (!AddInt32(item.y, item.height, displayMaxY)) { + MMI_HILOGE("The addition of displayMaxY overflows"); + return false; + } + if (((x >= item.x) && (x < displayMaxX)) && + (y >= item.y) && (y < displayMaxY)) { return true; } } @@ -430,8 +440,16 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi } auto physicalDisplayInfo = GetPhysicalDisplay(displayId); CHKPR(physicalDisplayInfo, ERROR_NULL_POINTER); - int32_t logicalX = pointerItem.GetDisplayX() + physicalDisplayInfo->x; - int32_t logicalY = pointerItem.GetDisplayY() + physicalDisplayInfo->y; + int32_t logicalX = 0; + int32_t logicalY = 0; + if (!AddInt32(pointerItem.GetDisplayX(), physicalDisplayInfo->x, logicalX)) { + MMI_HILOGE("The addition of logicalX overflows"); + return RET_ERR; + } + if (!AddInt32(pointerItem.GetDisplayY(), physicalDisplayInfo->y, logicalY)) { + MMI_HILOGE("The addition of logicalY overflows"); + return RET_ERR; + } IPointerDrawingManager::GetInstance()->DrawPointer(displayId, pointerItem.GetDisplayX(), pointerItem.GetDisplayY()); WindowInfo* touchWindow = nullptr; SelectWindowInfo(logicalX, logicalY, pointerEvent, touchWindow); @@ -481,8 +499,16 @@ int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptrx; - int32_t logicalY = physicalY + physicDisplayInfo->y; + int32_t logicalX = 0; + int32_t logicalY = 0; + if (!AddInt32(physicalX, physicDisplayInfo->x, logicalX)) { + MMI_HILOGE("The addition of logicalX overflows"); + return RET_ERR; + } + if (!AddInt32(physicalY, physicDisplayInfo->y, logicalY)) { + MMI_HILOGE("The addition of logicalY overflows"); + return RET_ERR; + } WindowInfo *touchWindow = nullptr; auto targetWindowId = pointerItem.GetTargetWindowId(); for (auto &item : displayGroupInfo_.windowsInfo) { @@ -574,11 +600,29 @@ bool InputWindowsManager::IsInsideDisplay(const DisplayInfo& displayInfo, int32_ void InputWindowsManager::FindPhysicalDisplay(const DisplayInfo& displayInfo, int32_t& physicalX, int32_t& physicalY, int32_t& displayId) { - int32_t logicalX = physicalX + displayInfo.x; - int32_t logicalY = physicalY + displayInfo.y; + int32_t logicalX = 0; + int32_t logicalY = 0; + if (!AddInt32(physicalX, displayInfo.x, logicalX)) { + MMI_HILOGE("The addition of logicalX overflows"); + return; + } + if (!AddInt32(physicalY, displayInfo.y, logicalY)) { + MMI_HILOGE("The addition of logicalY overflows"); + return; + } for (const auto &item : displayGroupInfo_.displaysInfo) { - if ((logicalX >= item.x && logicalX < item.x + item.width) && - (logicalY >= item.y && logicalY < item.y + item.height)) { + int32_t displayMaxX = 0; + int32_t displayMaxY = 0; + if (!AddInt32(item.x, item.width, displayMaxX)) { + MMI_HILOGE("The addition of displayMaxX overflows"); + return; + } + if (!AddInt32(item.y, item.height, displayMaxY)) { + MMI_HILOGE("The addition of displayMaxY overflows"); + return; + } + if ((logicalX >= item.x && logicalX < displayMaxX) && + (logicalY >= item.y && logicalY < displayMaxY)) { physicalX = logicalX - item.x; physicalY = logicalY - item.y; displayId = item.id; diff --git a/util/socket/src/uds_session.cpp b/util/socket/src/uds_session.cpp index f3f515c536748f714f9124c1e9a9a96443ca4536..be30af283afef6f07cb8a87858588c50e4df48e3 100755 --- a/util/socket/src/uds_session.cpp +++ b/util/socket/src/uds_session.cpp @@ -142,8 +142,17 @@ void UDSSession::DelEvents(int32_t id) break; } } + if (events_.empty()) { + isANRProcess_ = false; + return; + } + int64_t endTime = 0; + if (!AddInt64(events_.begin()->eventTime, INPUT_UI_TIMEOUT_TIME, endTime)) { + MMI_HILOGE("The addition of endTime overflows"); + return; + } auto currentTime = GetSysClockTime(); - if (events_.empty() || (currentTime < (events_.begin()->eventTime + INPUT_UI_TIMEOUT_TIME))) { + if (currentTime < endTime) { isANRProcess_ = false; } }