summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanis Danisevskis <jdanis@google.com>2018-01-31 19:53:01 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-01-31 19:53:01 +0000
commit1200aa15a61822e36294518964519b6a2a0f8593 (patch)
treeee7cb8054d746be32ba04c5303f709d30e227100
parent8b86f605ae5a6f3fd49b2d6d163d9376c9f97939 (diff)
parentd72dd842f0a1545eed328507a0cfdb62f786f809 (diff)
downloadkeymaster-1200aa15a61822e36294518964519b6a2a0f8593.tar.gz
AuthorizationSet: Clear() should also reset the error_ field am: f9524f57bf
am: d72dd842f0 Change-Id: I8fce12e9cc76fd6b1759508ff9af1451cf5acc40
-rw-r--r--authorization_set.cpp1
-rw-r--r--authorization_set_test.cpp9
2 files changed, 10 insertions, 0 deletions
diff --git a/authorization_set.cpp b/authorization_set.cpp
index 0411075..63b4d96 100644
--- a/authorization_set.cpp
+++ b/authorization_set.cpp
@@ -501,6 +501,7 @@ void AuthorizationSet::Clear() {
memset_s(indirect_data_, 0, indirect_data_size_);
elems_size_ = 0;
indirect_data_size_ = 0;
+ error_ = OK;
}
void AuthorizationSet::FreeData() {
diff --git a/authorization_set_test.cpp b/authorization_set_test.cpp
index f3f4412..8c908c3 100644
--- a/authorization_set_test.cpp
+++ b/authorization_set_test.cpp
@@ -247,6 +247,15 @@ TEST(Deserialization, InvalidLengthField) {
EXPECT_EQ(AuthorizationSet::MALFORMED_DATA, deserialized.is_valid());
}
+TEST(Clear, ClearRecoversFromError) {
+ uint8_t buf[] = {0, 0, 0};
+ AuthorizationSet deserialized(buf, array_length(buf));
+ ASSERT_EQ(AuthorizationSet::MALFORMED_DATA, deserialized.is_valid());
+
+ deserialized.Clear();
+ ASSERT_EQ(AuthorizationSet::OK, deserialized.is_valid());
+}
+
static uint32_t read_uint32(const uint8_t* buf) {
uint32_t val;
memcpy(&val, buf, sizeof(val));