OSDN Git Service

Fix potential buffer overflow in mediadrmserver
authorJeff Tinker <jtinker@google.com>
Thu, 11 Jan 2018 08:14:53 +0000 (00:14 -0800)
committerRyan Longair <rlongair@google.com>
Thu, 18 Jan 2018 18:16:48 +0000 (10:16 -0800)
bug:71389378
test: gts media tests

Change-Id: Ic7d4b456bc874b92fbe202e3dafb7ceac747ebc7
(cherry picked from commit 5231cc164fe040a3ab5fcb28baae4e0a4f9fdf4c)

drm/libmediadrm/ICrypto.cpp

index 8506d95..37dc83b 100644 (file)
 
 //#define LOG_NDEBUG 0
 #define LOG_TAG "ICrypto"
-#include <utils/Log.h>
-
 #include <binder/Parcel.h>
 #include <binder/IMemory.h>
+#include <cutils/log.h>
 #include <media/ICrypto.h>
 #include <media/stagefright/MediaErrors.h>
 #include <media/stagefright/foundation/ADebug.h>
 #include <media/stagefright/foundation/AString.h>
+#include <utils/Log.h>
 
 namespace android {
 
@@ -362,6 +362,13 @@ status_t BnCrypto::onTransact(
                     reply->writeInt32(BAD_VALUE);
                     return OK;
                 }
+                sp<IMemory> dest = destination.mSharedMemory;
+                if (totalSize > dest->size() ||
+                        (size_t)dest->offset() > dest->size() - totalSize) {
+                    reply->writeInt32(BAD_VALUE);
+                    android_errorWriteLog(0x534e4554, "71389378");
+                    return OK;
+                }
             }
 
             AString errorDetailMsg;