Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea0521ba authored by Chia-I Wu's avatar Chia-I Wu Committed by MSe
Browse files

libgui: check for invalid slot in attachBuffer

Bug: 37478824
Test: manual
AOSP-Change-Id: I369337d53539bf7f7e3d925bccdae4045da1b404
(cherry picked from commit c79a2968)

CVE-2017-0667

Change-Id: I15290a700c2e0f0da9a44bb3131c4e38cadbaed3
parent a3a09ef6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <binder/Parcel.h>
#include <binder/IInterface.h>

#include <gui/BufferQueueDefs.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/IProducerListener.h>

@@ -170,8 +171,16 @@ public:
        if (result != NO_ERROR) {
            return result;
        }

        *slot = reply.readInt32();
        result = reply.readInt32();
        if (result == NO_ERROR &&
                (*slot < 0 || *slot >= BufferQueueDefs::NUM_BUFFER_SLOTS)) {
            ALOGE("attachBuffer returned invalid slot %d", *slot);
            android_errorWriteLog(0x534e4554, "37478824");
            return UNKNOWN_ERROR;
        }

        return result;
    }