diff options
author | Chad Brubaker <cbrubaker@google.com> | 2015-08-03 17:36:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-03 17:36:40 +0000 |
commit | 1c73457afe3cb0afbc2a2884c41cfdd1148aca36 (patch) | |
tree | 447c3c0d3d11b4ee799996a77142e28cecc790db | |
parent | 8f7f96213c1fc273fbf02731e1362978ad7ec08a (diff) | |
parent | b124c9e86a5f8466f527501c6677b4b1b165c0b1 (diff) | |
download | android_system_security-1c73457afe3cb0afbc2a2884c41cfdd1148aca36.tar.gz android_system_security-1c73457afe3cb0afbc2a2884c41cfdd1148aca36.tar.bz2 android_system_security-1c73457afe3cb0afbc2a2884c41cfdd1148aca36.zip |
am b124c9e8: Fix unchecked length in Blob creation
* commit 'b124c9e86a5f8466f527501c6677b4b1b165c0b1':
Fix unchecked length in Blob creation
-rw-r--r-- | keystore/keystore.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/keystore/keystore.cpp b/keystore/keystore.cpp index 987e306..605df3b 100644 --- a/keystore/keystore.cpp +++ b/keystore/keystore.cpp @@ -410,8 +410,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); |