summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Brubaker <cbrubaker@google.com>2015-08-03 17:45:13 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-08-03 17:45:13 +0000
commitfd1ad3790fb089485cf7afc07f8b9f53d4c3136a (patch)
tree262db76768c9f3017ee562807c41299956a0b80a
parent90c4779146c9ac154fe85cd6a0775f8e1fc29be8 (diff)
parent1c73457afe3cb0afbc2a2884c41cfdd1148aca36 (diff)
downloadandroid_system_security-fd1ad3790fb089485cf7afc07f8b9f53d4c3136a.tar.gz
android_system_security-fd1ad3790fb089485cf7afc07f8b9f53d4c3136a.tar.bz2
android_system_security-fd1ad3790fb089485cf7afc07f8b9f53d4c3136a.zip
am 1c73457a: am b124c9e8: Fix unchecked length in Blob creation
* commit '1c73457afe3cb0afbc2a2884c41cfdd1148aca36': Fix unchecked length in Blob creation
-rw-r--r--keystore/keystore.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/keystore/keystore.cpp b/keystore/keystore.cpp
index 63f7ee2..58d2fd6 100644
--- a/keystore/keystore.cpp
+++ b/keystore/keystore.cpp
@@ -485,8 +485,16 @@ static const uint8_t CURRENT_BLOB_VERSION = 2;
class Blob {
public:
- Blob(const uint8_t* value, int32_t valueLength, const uint8_t* info, uint8_t infoLength,
+ Blob(const uint8_t* value, size_t valueLength, const uint8_t* info, uint8_t infoLength,
BlobType type) {
+ if (valueLength > sizeof(mBlob.value)) {
+ valueLength = sizeof(mBlob.value);
+ ALOGW("Provided blob length too large");
+ }
+ if (infoLength + valueLength > sizeof(mBlob.value)) {
+ infoLength = sizeof(mBlob.value) - valueLength;
+ ALOGW("Provided info length too large");
+ }
mBlob.length = valueLength;
memcpy(mBlob.value, value, valueLength);