resolved conflicts for merge of 41ceb7db to master

Change-Id: I72c429dbf30f3313ca12ccee3cceb7ff6e49f719
diff --git a/keystore/IKeystoreService.cpp b/keystore/IKeystoreService.cpp
index e3f7602..5690b98 100644
--- a/keystore/IKeystoreService.cpp
+++ b/keystore/IKeystoreService.cpp
@@ -30,6 +30,7 @@
 
 namespace android {
 
+const ssize_t MAX_GENERATE_ARGS = 3;
 static keymaster_key_param_t* readParamList(const Parcel& in, size_t* length);
 
 KeystoreArg::KeystoreArg(const void* data, size_t len)
@@ -1333,6 +1334,9 @@
             int32_t argsPresent = data.readInt32();
             if (argsPresent == 1) {
                 ssize_t numArgs = data.readInt32();
+                if (numArgs > MAX_GENERATE_ARGS) {
+                    return BAD_VALUE;
+                }
                 if (numArgs > 0) {
                     for (size_t i = 0; i < (size_t) numArgs; i++) {
                         ssize_t inSize = data.readInt32();
diff --git a/keystore/keystore.cpp b/keystore/keystore.cpp
index cf799f1..9aefd74 100644
--- a/keystore/keystore.cpp
+++ b/keystore/keystore.cpp
@@ -504,6 +504,7 @@
 public:
     Blob(const uint8_t* value, int32_t valueLength, const uint8_t* info, uint8_t infoLength,
             BlobType type) {
+        memset(&mBlob, 0, sizeof(mBlob));
         mBlob.length = valueLength;
         memcpy(mBlob.value, value, valueLength);
 
@@ -524,7 +525,9 @@
         mBlob = b;
     }
 
-    Blob() {}
+    Blob() {
+        memset(&mBlob, 0, sizeof(mBlob));
+    }
 
     const uint8_t* getValue() const {
         return mBlob.value;