diff options
Diffstat (limited to 'drm/1.0')
-rw-r--r-- | drm/1.0/default/CryptoPlugin.cpp | 31 | ||||
-rw-r--r-- | drm/1.0/default/DrmFactory.cpp | 2 | ||||
-rw-r--r-- | drm/1.0/default/LegacyPluginPath.cpp | 16 | ||||
-rw-r--r-- | drm/1.0/default/include/PluginLoader.h | 5 |
4 files changed, 43 insertions, 11 deletions
diff --git a/drm/1.0/default/CryptoPlugin.cpp b/drm/1.0/default/CryptoPlugin.cpp index f9c868db8..19666f53a 100644 --- a/drm/1.0/default/CryptoPlugin.cpp +++ b/drm/1.0/default/CryptoPlugin.cpp @@ -102,11 +102,20 @@ namespace implementation { std::unique_ptr<android::CryptoPlugin::SubSample[]> legacySubSamples = std::make_unique<android::CryptoPlugin::SubSample[]>(subSamples.size()); + size_t destSize = 0; for (size_t i = 0; i < subSamples.size(); i++) { - legacySubSamples[i].mNumBytesOfClearData - = subSamples[i].numBytesOfClearData; - legacySubSamples[i].mNumBytesOfEncryptedData - = subSamples[i].numBytesOfEncryptedData; + uint32_t numBytesOfClearData = subSamples[i].numBytesOfClearData; + legacySubSamples[i].mNumBytesOfClearData = numBytesOfClearData; + uint32_t numBytesOfEncryptedData = subSamples[i].numBytesOfEncryptedData; + legacySubSamples[i].mNumBytesOfEncryptedData = numBytesOfEncryptedData; + if (__builtin_add_overflow(destSize, numBytesOfClearData, &destSize)) { + _hidl_cb(Status::BAD_VALUE, 0, "subsample clear size overflow"); + return Void(); + } + if (__builtin_add_overflow(destSize, numBytesOfEncryptedData, &destSize)) { + _hidl_cb(Status::BAD_VALUE, 0, "subsample encrypted size overflow"); + return Void(); + } } AString detailMessage; @@ -138,11 +147,25 @@ namespace implementation { _hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size"); return Void(); } + + if (destSize > destBuffer.size) { + _hidl_cb(Status::BAD_VALUE, 0, "subsample sum too large"); + return Void(); + } + + base = static_cast<uint8_t *>(static_cast<void *>(destBase->getPointer())); destPtr = static_cast<void *>(base + destination.nonsecureMemory.offset); } else if (destination.type == BufferType::NATIVE_HANDLE) { + if (!secure) { + _hidl_cb(Status::BAD_VALUE, 0, "native handle destination must be secure"); + return Void(); + } native_handle_t *handle = const_cast<native_handle_t *>( destination.secureMemory.getNativeHandle()); destPtr = static_cast<void *>(handle); + } else { + _hidl_cb(Status::BAD_VALUE, 0, "invalid destination type"); + return Void(); } ssize_t result = mLegacyPlugin->decrypt(secure, keyId.data(), iv.data(), legacyMode, legacyPattern, srcPtr, legacySubSamples.get(), diff --git a/drm/1.0/default/DrmFactory.cpp b/drm/1.0/default/DrmFactory.cpp index 7e5d998e4..05951d7c0 100644 --- a/drm/1.0/default/DrmFactory.cpp +++ b/drm/1.0/default/DrmFactory.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 The Android Open Source Project -` * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/drm/1.0/default/LegacyPluginPath.cpp b/drm/1.0/default/LegacyPluginPath.cpp index 369059d2c..d0a8f90a7 100644 --- a/drm/1.0/default/LegacyPluginPath.cpp +++ b/drm/1.0/default/LegacyPluginPath.cpp @@ -16,6 +16,8 @@ #include "LegacyPluginPath.h" +#include <unistd.h> + #include <cutils/properties.h> namespace android { @@ -24,12 +26,16 @@ namespace drm { namespace V1_0 { namespace implementation { +// 64-bit DRM depends on OEM libraries that aren't +// provided for all devices. If the drm hal service +// is running as 64-bit use the 64-bit libs, otherwise +// use the 32-bit libs. const char* getDrmPluginPath() { - if (property_get_bool("drm.64bit.enabled", false)) { - return "/vendor/lib64/mediadrm"; - } else { - return "/vendor/lib/mediadrm"; - } +#if defined(__LP64__) + return "/vendor/lib64/mediadrm"; +#else + return "/vendor/lib/mediadrm"; +#endif } } // namespace implementation diff --git a/drm/1.0/default/include/PluginLoader.h b/drm/1.0/default/include/PluginLoader.h index f387b3cbc..0c45fb3ef 100644 --- a/drm/1.0/default/include/PluginLoader.h +++ b/drm/1.0/default/include/PluginLoader.h @@ -85,7 +85,10 @@ class PluginLoader { libraries.push(library); T* result = createFactoryFunc(); return result; - } + } else { + ALOGE("Failed to lookup symbol %s in library %s: %s", + entry, path, library->lastError()); + } } return NULL; } |