summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Ryleev <gmar@google.com>2016-03-25 13:51:48 -0700
committerMichael Ryleev <gmar@google.com>2016-04-15 11:26:23 -0700
commit7b0e0d9530e3816b7e843a42805ae0c8bd01bfa4 (patch)
tree3e024a1a42346eb399c934c935a58335d001ae39
parentd83ce9281626eb700d539e87ba26557086e2e8e3 (diff)
downloadgatekeeper-7b0e0d9530e3816b7e843a42805ae0c8bd01bfa4.tar.gz
trusty_gatekeeper: fixup to accomodate changes with secure storage API
Fix potential storage session leak. Fixup couple warnings Change-Id: I1a4fb82a070bce55e201ccc8895f68900aaec922
-rw-r--r--trusty_gatekeeper.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/trusty_gatekeeper.cpp b/trusty_gatekeeper.cpp
index 08f7e7f..6e97ad8 100644
--- a/trusty_gatekeeper.cpp
+++ b/trusty_gatekeeper.cpp
@@ -201,15 +201,16 @@ bool TrustyGateKeeper::GetSecureFailureRecord(uint32_t uid, secure_id_t user_id,
file_handle_t handle;
snprintf(id, STORAGE_ID_LENGTH_MAX, GATEKEEPER_PREFIX "%u", uid);
- rc = storage_open_file(session, &handle, id, 0);
+ rc = storage_open_file(session, &handle, id, 0, 0);
if (rc < 0) {
TLOGE("Error:[%d] opening storage object.\n", rc);
+ storage_close_session(session);
return false;
}
failure_record_t owner_record;
- rc = storage_read(session, handle, 0, &owner_record, sizeof(owner_record));
- storage_close_file(session, handle);
+ rc = storage_read(handle, 0, &owner_record, sizeof(owner_record));
+ storage_close_file(handle);
storage_close_session(session);
if (rc < 0) {
@@ -251,7 +252,7 @@ bool TrustyGateKeeper::ClearFailureRecord(uint32_t uid, secure_id_t user_id, boo
bool TrustyGateKeeper::WriteSecureFailureRecord(uint32_t uid, failure_record_t *record) {
storage_session_t session;
- long rc = storage_open_session(&session, STORAGE_CLIENT_TD_PORT);
+ int rc = storage_open_session(&session, STORAGE_CLIENT_TD_PORT);
if (rc < 0) {
TLOGE("Error: [%d] failed to open storage session\n", rc);
return false;
@@ -262,14 +263,15 @@ bool TrustyGateKeeper::WriteSecureFailureRecord(uint32_t uid, failure_record_t *
snprintf(id, STORAGE_ID_LENGTH_MAX, GATEKEEPER_PREFIX "%u", uid);
file_handle_t handle;
- rc = storage_open_file(session, &handle, id, STORAGE_FILE_OPEN_CREATE);
+ rc = storage_open_file(session, &handle, id, STORAGE_FILE_OPEN_CREATE, 0);
if (rc < 0) {
TLOGE("Error: [%d] failed to open storage object %s\n", rc, id);
+ storage_close_session(session);
return false;
}
- rc = storage_write(session, handle, 0, record, sizeof(*record));
- storage_close_file(session, handle);
+ rc = storage_write(handle, 0, record, sizeof(*record), STORAGE_OP_COMPLETE);
+ storage_close_file(handle);
storage_close_session(session);
if (rc < 0) {