summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-03-27 08:25:11 +0200
committerTao Bao <tbao@google.com>2017-03-27 08:34:13 +0200
commit056e2da6790a5111039ef2e1310ad781107f80d4 (patch)
tree48009c631fce457ea755bee82ecee4b3a2e94404
parentMerge "Skip logging the warning for uncrypt_status for devices w/o /cache" into nyc-mr2-dev-plus-aosp (diff)
downloadandroid_bootable_recovery-056e2da6790a5111039ef2e1310ad781107f80d4.tar
android_bootable_recovery-056e2da6790a5111039ef2e1310ad781107f80d4.tar.gz
android_bootable_recovery-056e2da6790a5111039ef2e1310ad781107f80d4.tar.bz2
android_bootable_recovery-056e2da6790a5111039ef2e1310ad781107f80d4.tar.lz
android_bootable_recovery-056e2da6790a5111039ef2e1310ad781107f80d4.tar.xz
android_bootable_recovery-056e2da6790a5111039ef2e1310ad781107f80d4.tar.zst
android_bootable_recovery-056e2da6790a5111039ef2e1310ad781107f80d4.zip
-rw-r--r--tests/component/verifier_test.cpp20
-rw-r--r--tests/testdata/signature-boundary.zipbin22 -> 0 bytes
2 files changed, 18 insertions, 2 deletions
diff --git a/tests/component/verifier_test.cpp b/tests/component/verifier_test.cpp
index 4993716f4..4c0648714 100644
--- a/tests/component/verifier_test.cpp
+++ b/tests/component/verifier_test.cpp
@@ -33,6 +33,8 @@
#include "otautil/SysUtil.h"
#include "verifier.h"
+using namespace std::string_literals;
+
class VerifierTest : public testing::TestWithParam<std::vector<std::string>> {
protected:
void SetUp() override {
@@ -115,6 +117,21 @@ TEST(VerifierTest, load_keys_invalid_keys) {
ASSERT_FALSE(load_keys(key_file5.path, certs));
}
+TEST(VerifierTest, BadPackage_SignatureStartOutOfBounds) {
+ std::string testkey_v3;
+ ASSERT_TRUE(android::base::ReadFileToString(from_testdata_base("testkey_v3.txt"), &testkey_v3));
+
+ TemporaryFile key_file;
+ ASSERT_TRUE(android::base::WriteStringToFile(testkey_v3, key_file.path));
+ std::vector<Certificate> certs;
+ ASSERT_TRUE(load_keys(key_file.path, certs));
+
+ // Signature start is 65535 (0xffff) while comment size is 0 (Bug: 31914369).
+ std::string package = "\x50\x4b\x05\x06"s + std::string(12, '\0') + "\xff\xff\xff\xff\x00\x00"s;
+ ASSERT_EQ(VERIFY_FAILURE, verify_file(reinterpret_cast<const unsigned char*>(package.data()),
+ package.size(), certs));
+}
+
TEST_P(VerifierSuccessTest, VerifySucceed) {
ASSERT_EQ(verify_file(memmap.addr, memmap.length, certs, nullptr), VERIFY_SUCCESS);
}
@@ -159,5 +176,4 @@ INSTANTIATE_TEST_CASE_P(BadPackage, VerifierFailureTest,
std::vector<std::string>({"random.zip", "v1"}),
std::vector<std::string>({"fake-eocd.zip", "v1"}),
std::vector<std::string>({"alter-metadata.zip", "v1"}),
- std::vector<std::string>({"alter-footer.zip", "v1"}),
- std::vector<std::string>({"signature-boundary.zip", "v1"})));
+ std::vector<std::string>({"alter-footer.zip", "v1"})));
diff --git a/tests/testdata/signature-boundary.zip b/tests/testdata/signature-boundary.zip
deleted file mode 100644
index 64a3cfa15..000000000
--- a/tests/testdata/signature-boundary.zip
+++ /dev/null
Binary files differ