From ffbd83c6226273ae00781f42e52f485d895ee864 Mon Sep 17 00:00:00 2001 From: Harry Cutts Date: Mon, 18 Nov 2024 19:08:04 +0000 Subject: input: don't log the whole MotionEvent in index checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We've had a crash report where this causes infinite recursion, probably through the following call sequence: operator<<(std::ostream&, const MotionEvent&) → MotionEvent::get(X|Y) → MotionEvent::getAxisValue → MotionEvent::getHistoricalAxisValue → MotionEvent::getHistoricalRawPointerCoords → operator<<(std::ostream&, const MotionEvent&) It's unclear how the MotionEvent gets corrupted such that getHistoricalRawPointerCoords is called with invalid indexes, but the simple fix is to only log a useful subset of the whole event in these checks. Bug: 379368465 Test: m checkinput Flag: EXEMPT bug fix Change-Id: I0822f88fc7da6ba08ba6dbbab71ca5aaf78fc35d --- libs/input/Input.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libs/input/Input.cpp') diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index a2bb3453fe..b87a7068b5 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -705,15 +705,17 @@ float MotionEvent::getAxisValue(int32_t axis, size_t pointerIndex) const { const PointerCoords* MotionEvent::getHistoricalRawPointerCoords( size_t pointerIndex, size_t historicalIndex) const { if (CC_UNLIKELY(pointerIndex < 0 || pointerIndex >= getPointerCount())) { - LOG(FATAL) << __func__ << ": Invalid pointer index " << pointerIndex << " for " << *this; + LOG(FATAL) << __func__ << ": Invalid pointer index " << pointerIndex + << "; should be between >0 and ≤" << getPointerCount(); } if (CC_UNLIKELY(historicalIndex < 0 || historicalIndex > getHistorySize())) { - LOG(FATAL) << __func__ << ": Invalid historical index " << historicalIndex << " for " - << *this; + LOG(FATAL) << __func__ << ": Invalid historical index " << historicalIndex + << "; should be >0 and ≤" << getHistorySize(); } const size_t position = historicalIndex * getPointerCount() + pointerIndex; if (CC_UNLIKELY(position < 0 || position >= mSamplePointerCoords.size())) { - LOG(FATAL) << __func__ << ": Invalid array index " << position << " for " << *this; + LOG(FATAL) << __func__ << ": Invalid array index " << position << "; should be >0 and ≤" + << mSamplePointerCoords.size(); } return &mSamplePointerCoords[position]; } -- cgit v1.2.3-59-g8ed1b