OSDN Git Service

Fix stack use-after-scope in InputReader
authorMichael Spang <spang@google.com>
Wed, 6 Sep 2017 00:17:16 +0000 (20:17 -0400)
committerMichael Spang <spang@google.com>
Wed, 6 Sep 2017 00:18:49 +0000 (20:18 -0400)
READ of size 4 at 0x0079b1ac3a20 thread T121 (InputReader)

Viewport [1] to add: virtual:android:277f1a09-b88d-4d1e-8716-796f114d080b
   #0 0x79b8820d53 in android::InputReaderConfiguration::getDisplayViewport(android::ViewportType, android::String8 const*, android::DisplayViewport*) const frameworks/native/services/inputflinger/InputReader.cpp:246:39
   #1 0x79b8843fab in android::TouchInputMapper::configureSurface(long, bool*) frameworks/native/services/inputflinger/InputReader.cpp:3472:22
   #2 0x79b88411b3 in android::TouchInputMapper::configure(long, android::InputReaderConfiguration const*, unsigned int) frameworks/native/services/inputflinger/InputReader.cpp:3248:9
   #3 0x79b8825ff3 in android::InputDevice::configure(long, android::InputReaderConfiguration const*, unsigned int) frameworks/native/services/inputflinger/InputReader.cpp:1126:21
   #4 0x79b8822653 in android::InputReader::refreshConfigurationLocked(unsigned int) frameworks/native/services/inputflinger/InputReader.cpp:612:25
   #5 0x79b88239fb in android::InputReader::loopOnce() frameworks/native/services/inputflinger/InputReader.cpp:343:13
   #6 0x79b882d507 in android::InputReaderThread::threadLoop() frameworks/native/services/inputflinger/InputReader.cpp:1004:14
   #7 0x79d79e6113 in android::Thread::_threadLoop(void*) system/core/libutils/Threads.cpp:747:28
   #8 0x79da914bbb in android::AndroidRuntime::javaThreadShell(void*) frameworks/base/core/jni/AndroidRuntime.cpp:1199:14
   #9 0x79da20f31b in __pthread_start(void*) bionic/libc/bionic/pthread_create.cpp:214:18
   #10 0x79da1c6dff in __start_thread bionic/libc/bionic/clone.cpp:47:16

Bug: 65378805
Test: asan build
Change-Id: I5a65cb007fe4879ce9635572014a568583a2ef4a

services/inputflinger/InputReader.cpp

index 935d0f6..d4266f6 100644 (file)
@@ -257,7 +257,7 @@ bool InputReaderConfiguration::getDisplayViewport(ViewportType viewportType,
         const String8* uniqueDisplayId, DisplayViewport* outViewport) const {
     const DisplayViewport* viewport = NULL;
     if (viewportType == ViewportType::VIEWPORT_VIRTUAL && uniqueDisplayId != NULL) {
-        for (DisplayViewport currentViewport : mVirtualDisplays) {
+        for (const DisplayViewport& currentViewport : mVirtualDisplays) {
             if (currentViewport.uniqueId == *uniqueDisplayId) {
                 viewport = &currentViewport;
                 break;