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
This commit is contained in:
parent
e185fae205
commit
168228a933
1 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue