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

Commit 636050c0 authored by Marco Nelissen's avatar Marco Nelissen Committed by Abhisek Devkota
Browse files

Add some sanity checks

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


namespace android {
namespace android {


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


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


        if (len > 0) {
        if (len > size) {
            memcpy(buffer, mMemory->pointer(), len);
            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;
        return len;
    }
    }