Fixed two bugs that broke the keystore granting mechanism

Bug: 65851049

Merged-In: Ibea71d42934d283c95729eca6772a9aadb949a6a
Change-Id: Ibea71d42934d283c95729eca6772a9aadb949a6a
diff --git a/keystore/key_store_service.cpp b/keystore/key_store_service.cpp
index 310d8e2..c8842c5 100644
--- a/keystore/key_store_service.cpp
+++ b/keystore/key_store_service.cpp
@@ -526,7 +526,7 @@
         return String16();
     }
 
-    return String16(mKeyStore->addGrant(String8(name).string(), granteeUid, callingUid).c_str());
+    return String16(mKeyStore->addGrant(String8(name).string(), callingUid, granteeUid).c_str());
 }
 
 KeyStoreServiceReturnCode KeyStoreService::ungrant(const String16& name, int32_t granteeUid) {
diff --git a/keystore/keystore.cpp b/keystore/keystore.cpp
index 5451ace..18ecb4a 100644
--- a/keystore/keystore.cpp
+++ b/keystore/keystore.cpp
@@ -522,7 +522,7 @@
     // They might be using a granted key.
     auto grant = mGrants.get(uid, keyName.string());
     if (!grant) return ResponseCode::KEY_NOT_FOUND;
-    filepath8.format("%s/%s", grant->owner_dir_name_.c_str(),
+    filepath8 = String8::format("%s/%s", grant->owner_dir_name_.c_str(),
             getKeyNameForUid(String8(grant->alias_.c_str()), grant->owner_uid_, type).c_str());
 
     // It is a granted key. Try to load it.