diff options
author | David Drysdale <drysdale@google.com> | 2021-10-05 08:43:52 +0100 |
---|---|---|
committer | David Drysdale <drysdale@google.com> | 2021-10-05 08:56:39 +0100 |
commit | 168228a9330e4f6ef14bcfa77681e1640b4df82c (patch) | |
tree | 16d5a62f1cdd99b0e15d777caffbe4871c7d2f3a | |
parent | e185fae2054ffe734a26611149f3c5635630bb06 (diff) |
KeyMint VTS: don't crash on invalid patchlevel
If vendor/boot patchlevel is shorter than the expected YYYYMMDD format,
fail properly rather than crashing the VTS test process.
Bug: 201946955
Test: VtsAidlKeyMintTargetTest
Change-Id: Icf3541e1b76675871672edec8590ec1821770acf
-rw-r--r-- | security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp index fb720e8f46..37acfa9032 100644 --- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp +++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp @@ -1365,11 +1365,16 @@ bool verify_attestation_record(const string& challenge, // att_hw_enforced[i].tag == TAG_VENDOR_PATCHLEVEL) { std::string date = std::to_string(att_hw_enforced[i].value.get<KeyParameterValue::integer>()); + // strptime seems to require delimiters, but the tag value will // be YYYYMMDD + if (date.size() != 8) { + ADD_FAILURE() << "Tag " << att_hw_enforced[i].tag + << " with invalid format (not YYYYMMDD): " << date; + return false; + } date.insert(6, "-"); date.insert(4, "-"); - EXPECT_EQ(date.size(), 10); struct tm time; strptime(date.c_str(), "%Y-%m-%d", &time); |