twrpinstall: Switch to ZipEntry64
The libziparchive TWRP using was outdated, not supported a zip
size more than 4 GiB. With the development of technologies,
Obviously it was not enough for ROM packages, like Xiaomi's
MIUI for Vitrual A/B devices (for example Redmi K40 [alioth])
is more than 4 GiB and TWRP couldn't handle it properly.
Since we have updated libziparchive to latest version, we could
switch ZipEntry to ZipEntry64 so that TWRP can support a ROM
package if its size more than 4 GiB.
Co-authored-by: sekaiacg <sekaiacg@gmail.com>
Signed-off-by: GarfieldHan <2652609017@qq.com>
Change-Id: Iee811554bb08e02bf2bd8e9057511f36caefdc9d
diff --git a/twrpinstall/installcommand.cpp b/twrpinstall/installcommand.cpp
index 9836014..ad7a772 100755
--- a/twrpinstall/installcommand.cpp
+++ b/twrpinstall/installcommand.cpp
@@ -55,7 +55,7 @@
bool read_metadata_from_package(ZipArchiveHandle zip, std::string* meta_data) {
std::string binary_name(METADATA_PATH);
- ZipEntry binary_entry;
+ ZipEntry64 binary_entry;
if (FindEntry(zip, binary_name, &binary_entry) == 0) {
long size = binary_entry.uncompressed_length;
if (size <= 0)
@@ -201,7 +201,7 @@
// the RAW payload offset in the zip file.
// if (!Zip->EntryExists(AB_OTA_PAYLOAD_PROPERTIES)) {
std::string binary_name(AB_OTA_PAYLOAD_PROPERTIES);
- ZipEntry binary_entry;
+ ZipEntry64 binary_entry;
if (FindEntry(Zip, binary_name, &binary_entry) != 0) {
printf("Can't find %s\n", AB_OTA_PAYLOAD_PROPERTIES);
return INSTALL_CORRUPT;
@@ -216,7 +216,7 @@
}
std::string ab_ota_payload(AB_OTA_PAYLOAD);
- ZipEntry ab_ota_payload_entry;
+ ZipEntry64 ab_ota_payload_entry;
if (FindEntry(Zip, ab_ota_payload, &ab_ota_payload_entry) != 0) {
printf("Can't find %s\n", AB_OTA_PAYLOAD);
return INSTALL_CORRUPT;
@@ -277,7 +277,7 @@
static constexpr const char* COMPATIBILITY_ZIP_ENTRY = "compatibility.zip";
std::string compatibility_entry_name(COMPATIBILITY_ZIP_ENTRY);
- ZipEntry compatibility_entry;
+ ZipEntry64 compatibility_entry;
if (FindEntry(zw, compatibility_entry_name, &compatibility_entry) != 0) {
printf("Package doesn't contain %s entry\n", COMPATIBILITY_ZIP_ENTRY);
return true;
@@ -311,7 +311,7 @@
std::unique_ptr<void, decltype(&EndIteration)> guard(cookie, EndIteration);
std::vector<std::string> compatibility_info;
- ZipEntry info_entry;
+ ZipEntry64 info_entry;
std::string info_name;
while (Next(cookie, &info_entry, &info_name) == 0) {
std::string content(info_entry.uncompressed_length, '\0');