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

Commit 59cea261 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Add some sanity checks

Bug: 19400722
Change-Id: Ib3afdf73fd4647eeea5721c61c8b72dbba0647f6
parent eb204f82
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <binder/Parcel.h>
#include <utils/String8.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaErrors.h>

namespace android {

@@ -106,12 +107,19 @@ struct BpMediaHTTPConnection : public BpInterface<IMediaHTTPConnection> {
            return UNKNOWN_ERROR;
        }

        int32_t len = reply.readInt32();
        size_t len = reply.readInt32();

        if (len > 0) {
            memcpy(buffer, mMemory->pointer(), len);
        if (len > size) {
            ALOGE("requested %zu, got %zu", size, len);
            return ERROR_OUT_OF_RANGE;
        }
        if (len > mMemory->size()) {
            ALOGE("got %zu, but memory has %zu", len, mMemory->size());
            return ERROR_OUT_OF_RANGE;
        }

        memcpy(buffer, mMemory->pointer(), len);

        return len;
    }