diff options
author | Marco Nelissen <marcone@google.com> | 2015-05-06 22:48:44 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-05-06 22:48:44 +0000 |
commit | d8e41553b96432c4d4dae80fcc042b95fd9d27d9 (patch) | |
tree | 8dbbd8d07f670ca1c56a6519d80b38fb5f61b5eb /media/libmedia | |
parent | a05bd3c1cdff400ad92532b06d40ddc5c638c284 (diff) | |
parent | bd28ac7471e2c7cab0ce9df4c2d5a295adc163a1 (diff) | |
download | frameworks_av-d8e41553b96432c4d4dae80fcc042b95fd9d27d9.zip frameworks_av-d8e41553b96432c4d4dae80fcc042b95fd9d27d9.tar.gz frameworks_av-d8e41553b96432c4d4dae80fcc042b95fd9d27d9.tar.bz2 |
am bd28ac74: am 59cea261: Add some sanity checks
* commit 'bd28ac7471e2c7cab0ce9df4c2d5a295adc163a1':
Add some sanity checks
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/IMediaHTTPConnection.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/media/libmedia/IMediaHTTPConnection.cpp b/media/libmedia/IMediaHTTPConnection.cpp index 7e26ee6..a5a3714 100644 --- a/media/libmedia/IMediaHTTPConnection.cpp +++ b/media/libmedia/IMediaHTTPConnection.cpp @@ -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,11 +107,18 @@ 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; } |