summaryrefslogtreecommitdiffstats
path: root/drm
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-03-13 19:20:55 -0700
committerJames Dong <jdong@google.com>2012-03-13 19:23:23 -0700
commit32d8fc8d6d77eef02077142feb8bd9c7ee2cbe8f (patch)
tree2ae344ce78f81a99ddae06fe12ed75625673552c /drm
parent958ec9d0b2f2063a03d3ea2b9bb86897125401b0 (diff)
downloadframeworks_base-32d8fc8d6d77eef02077142feb8bd9c7ee2cbe8f.zip
frameworks_base-32d8fc8d6d77eef02077142feb8bd9c7ee2cbe8f.tar.gz
frameworks_base-32d8fc8d6d77eef02077142feb8bd9c7ee2cbe8f.tar.bz2
Fixed a buffer overflow bug in DrmPassthruPlugin
Change-Id: I8df2a90409c9266a094a1a0904a5ff76ec483d16
Diffstat (limited to 'drm')
-rw-r--r--drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
index 0ffc0a7..77db32c 100644
--- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
+++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
@@ -279,8 +279,14 @@ status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle
* memory has to be allocated by the caller.
*/
if (NULL != (*decBuffer) && 0 < (*decBuffer)->length) {
- memcpy((*decBuffer)->data, encBuffer->data, encBuffer->length);
- (*decBuffer)->length = encBuffer->length;
+ if ((*decBuffer)->length >= encBuffer->length) {
+ memcpy((*decBuffer)->data, encBuffer->data, encBuffer->length);
+ (*decBuffer)->length = encBuffer->length;
+ } else {
+ ALOGE("decBuffer size (%d) too small to hold %d bytes",
+ (*decBuffer)->length, encBuffer->length);
+ return DRM_ERROR_UNKNOWN;
+ }
}
return DRM_NO_ERROR;
}