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

Commit d8e41553 authored by Marco Nelissen's avatar Marco Nelissen Committed by Android Git Automerger
Browse files

am bd28ac74: am 59cea261: Add some sanity checks

* commit 'bd28ac74':
  Add some sanity checks
parents a05bd3c1 bd28ac74
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;
    }