diff options
-rw-r--r-- | applypatch/imgdiff.cpp | 12 | ||||
-rw-r--r-- | applypatch/include/applypatch/imgdiff_image.h | 5 | ||||
-rw-r--r-- | tests/component/updater_test.cpp | 2 | ||||
-rw-r--r-- | tests/component/verifier_test.cpp | 30 | ||||
-rw-r--r-- | tools/recovery_l10n/res/values-hi/strings.xml | 2 | ||||
-rw-r--r-- | tools/recovery_l10n/res/values-mr/strings.xml | 8 | ||||
-rw-r--r-- | tools/recovery_l10n/res/values-pa/strings.xml | 6 | ||||
-rw-r--r-- | tools/recovery_l10n/res/values-te/strings.xml | 2 |
8 files changed, 35 insertions, 32 deletions
diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp index 69ad75f37..f57e7942c 100644 --- a/applypatch/imgdiff.cpp +++ b/applypatch/imgdiff.cpp @@ -163,7 +163,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> -#include <bsdiff.h> +#include <bsdiff/bsdiff.h> #include <ziparchive/zip_archive.h> #include <zlib.h> @@ -324,7 +324,8 @@ void ImageChunk::MergeAdjacentNormal(const ImageChunk& other) { } bool ImageChunk::MakePatch(const ImageChunk& tgt, const ImageChunk& src, - std::vector<uint8_t>* patch_data, saidx_t** bsdiff_cache) { + std::vector<uint8_t>* patch_data, + bsdiff::SuffixArrayIndexInterface** bsdiff_cache) { #if defined(__ANDROID__) char ptemp[] = "/data/local/tmp/imgdiff-patch-XXXXXX"; #else @@ -1083,7 +1084,7 @@ bool ZipModeImage::GeneratePatchesInternal(const ZipModeImage& tgt_image, printf("Construct patches for %zu chunks...\n", tgt_image.NumOfChunks()); patch_chunks->clear(); - saidx_t* bsdiff_cache = nullptr; + bsdiff::SuffixArrayIndexInterface* bsdiff_cache = nullptr; for (size_t i = 0; i < tgt_image.NumOfChunks(); i++) { const auto& tgt_chunk = tgt_image[i]; @@ -1097,7 +1098,8 @@ bool ZipModeImage::GeneratePatchesInternal(const ZipModeImage& tgt_image, : src_image.FindChunkByName(tgt_chunk.GetEntryName()); const auto& src_ref = (src_chunk == nullptr) ? src_image.PseudoSource() : *src_chunk; - saidx_t** bsdiff_cache_ptr = (src_chunk == nullptr) ? &bsdiff_cache : nullptr; + bsdiff::SuffixArrayIndexInterface** bsdiff_cache_ptr = + (src_chunk == nullptr) ? &bsdiff_cache : nullptr; std::vector<uint8_t> patch_data; if (!ImageChunk::MakePatch(tgt_chunk, src_ref, &patch_data, bsdiff_cache_ptr)) { @@ -1114,7 +1116,7 @@ bool ZipModeImage::GeneratePatchesInternal(const ZipModeImage& tgt_image, patch_chunks->emplace_back(tgt_chunk, src_ref, std::move(patch_data)); } } - free(bsdiff_cache); + delete bsdiff_cache; CHECK_EQ(patch_chunks->size(), tgt_image.NumOfChunks()); return true; diff --git a/applypatch/include/applypatch/imgdiff_image.h b/applypatch/include/applypatch/imgdiff_image.h index 3d29547cb..00a84f3a9 100644 --- a/applypatch/include/applypatch/imgdiff_image.h +++ b/applypatch/include/applypatch/imgdiff_image.h @@ -24,7 +24,7 @@ #include <string> #include <vector> -#include <bsdiff.h> +#include <bsdiff/bsdiff.h> #include <ziparchive/zip_archive.h> #include <zlib.h> @@ -98,7 +98,8 @@ class ImageChunk { * repeatedly, pass nullptr if not needed. */ static bool MakePatch(const ImageChunk& tgt, const ImageChunk& src, - std::vector<uint8_t>* patch_data, saidx_t** bsdiff_cache); + std::vector<uint8_t>* patch_data, + bsdiff::SuffixArrayIndexInterface** bsdiff_cache); private: const uint8_t* GetRawData() const; diff --git a/tests/component/updater_test.cpp b/tests/component/updater_test.cpp index 266657d31..d9d01d427 100644 --- a/tests/component/updater_test.cpp +++ b/tests/component/updater_test.cpp @@ -33,7 +33,7 @@ #include <android-base/test_utils.h> #include <bootloader_message/bootloader_message.h> #include <brotli/encode.h> -#include <bsdiff.h> +#include <bsdiff/bsdiff.h> #include <gtest/gtest.h> #include <ziparchive/zip_archive.h> #include <ziparchive/zip_writer.h> diff --git a/tests/component/verifier_test.cpp b/tests/component/verifier_test.cpp index e520f5028..2ef3828ad 100644 --- a/tests/component/verifier_test.cpp +++ b/tests/component/verifier_test.cpp @@ -117,21 +117,6 @@ 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(VerifierTest, BadPackage_AlteredFooter) { std::string testkey_v3; ASSERT_TRUE(android::base::ReadFileToString(from_testdata_base("testkey_v3.txt"), &testkey_v3)); @@ -177,6 +162,21 @@ TEST(VerifierTest, BadPackage_AlteredContent) { 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); } diff --git a/tools/recovery_l10n/res/values-hi/strings.xml b/tools/recovery_l10n/res/values-hi/strings.xml index a8a876ee4..65d003352 100644 --- a/tools/recovery_l10n/res/values-hi/strings.xml +++ b/tools/recovery_l10n/res/values-hi/strings.xml @@ -3,7 +3,7 @@ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="recovery_installing" msgid="2013591905463558223">"सिस्टम अपडेट इंस्टॉल किया जा रहा है"</string> <string name="recovery_erasing" msgid="7334826894904037088">"मिटाया जा रहा है"</string> - <string name="recovery_no_command" msgid="4465476568623024327">"कोई आदेश नहीं"</string> + <string name="recovery_no_command" msgid="4465476568623024327">"कोई निर्देश नहीं मिला"</string> <string name="recovery_error" msgid="5748178989622716736">"गड़बड़ी!"</string> <string name="recovery_installing_security" msgid="9184031299717114342">"सुरक्षा अपडेट इंस्टॉल किया जा रहा है"</string> </resources> diff --git a/tools/recovery_l10n/res/values-mr/strings.xml b/tools/recovery_l10n/res/values-mr/strings.xml index 8cf86f773..5f820336f 100644 --- a/tools/recovery_l10n/res/values-mr/strings.xml +++ b/tools/recovery_l10n/res/values-mr/strings.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="recovery_installing" msgid="2013591905463558223">"सिस्टम अद्यतन स्थापित करीत आहे"</string> + <string name="recovery_installing" msgid="2013591905463558223">"सिस्टम अपडेट इंस्टॉल करत आहे"</string> <string name="recovery_erasing" msgid="7334826894904037088">"मिटवत आहे"</string> - <string name="recovery_no_command" msgid="4465476568623024327">"कोणताही आदेश नाही"</string> - <string name="recovery_error" msgid="5748178989622716736">"त्रुटी!"</string> - <string name="recovery_installing_security" msgid="9184031299717114342">"सुरक्षा अद्यतन स्थापित करीत आहे"</string> + <string name="recovery_no_command" msgid="4465476568623024327">"कोणतीही कमांड नाही"</string> + <string name="recovery_error" msgid="5748178989622716736">"एरर!"</string> + <string name="recovery_installing_security" msgid="9184031299717114342">"सुरक्षा अपडेट इंस्टॉल करत आहे"</string> </resources> diff --git a/tools/recovery_l10n/res/values-pa/strings.xml b/tools/recovery_l10n/res/values-pa/strings.xml index 8564c9c36..27972d117 100644 --- a/tools/recovery_l10n/res/values-pa/strings.xml +++ b/tools/recovery_l10n/res/values-pa/strings.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="recovery_installing" msgid="2013591905463558223">"ਸਿਸਟਮ ਅੱਪਡੇਟ ਸਥਾਪਤ ਕੀਤੀ ਜਾ ਰਹੀ ਹੈ"</string> + <string name="recovery_installing" msgid="2013591905463558223">"ਸਿਸਟਮ ਅੱਪਡੇਟ ਸਥਾਪਤ ਕੀਤਾ ਜਾ ਰਿਹਾ ਹੈ"</string> <string name="recovery_erasing" msgid="7334826894904037088">"ਮਿਟਾਈ ਜਾ ਰਹੀ ਹੈ"</string> - <string name="recovery_no_command" msgid="4465476568623024327">"ਕੋਈ ਕਮਾਂਡ ਨਹੀਂ"</string> + <string name="recovery_no_command" msgid="4465476568623024327">"ਕੋਈ ਆਦੇਸ਼ ਨਹੀਂ"</string> <string name="recovery_error" msgid="5748178989622716736">"ਅਸ਼ੁੱਧੀ!"</string> - <string name="recovery_installing_security" msgid="9184031299717114342">"ਸੁਰੱਖਿਆ ਅੱਪਡੇਟ ਸਥਾਪਤ ਕੀਤੀ ਜਾ ਰਹੀ ਹੈ"</string> + <string name="recovery_installing_security" msgid="9184031299717114342">"ਸੁਰੱਖਿਆ ਅੱਪਡੇਟ ਸਥਾਪਤ ਕੀਤਾ ਜਾ ਰਿਹਾ ਹੈ"</string> </resources> diff --git a/tools/recovery_l10n/res/values-te/strings.xml b/tools/recovery_l10n/res/values-te/strings.xml index cfb02c915..e35c82bc4 100644 --- a/tools/recovery_l10n/res/values-te/strings.xml +++ b/tools/recovery_l10n/res/values-te/strings.xml @@ -4,6 +4,6 @@ <string name="recovery_installing" msgid="2013591905463558223">"సిస్టమ్ నవీకరణను ఇన్స్టాల్ చేస్తోంది"</string> <string name="recovery_erasing" msgid="7334826894904037088">"డేటాను తొలగిస్తోంది"</string> <string name="recovery_no_command" msgid="4465476568623024327">"ఆదేశం లేదు"</string> - <string name="recovery_error" msgid="5748178989622716736">"లోపం సంభవించింది!"</string> + <string name="recovery_error" msgid="5748178989622716736">"ఎర్రర్ సంభవించింది!"</string> <string name="recovery_installing_security" msgid="9184031299717114342">"భద్రతా నవీకరణను ఇన్స్టాల్ చేస్తోంది"</string> </resources> |