From b407414fd01eac44eb94d6d95f765c744e1ffa0e Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 15 Sep 2020 14:26:17 -0700 Subject: [PATCH] fastboot: switch to ZipEntry64. Test: treehugger Change-Id: I17a023f113590e469f69174f7004c4579255c6ed --- fastboot/fastboot.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 3969367b0..0921d72ae 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -527,12 +527,15 @@ static std::vector LoadBootableImage(const std::string& kernel, const std: static bool UnzipToMemory(ZipArchiveHandle zip, const std::string& entry_name, std::vector* out) { - ZipEntry zip_entry; + ZipEntry64 zip_entry; if (FindEntry(zip, entry_name, &zip_entry) != 0) { fprintf(stderr, "archive does not contain '%s'\n", entry_name.c_str()); return false; } + if (zip_entry.uncompressed_length > std::numeric_limits::max()) { + die("entry '%s' is too large: %" PRIu64, entry_name.c_str(), zip_entry.uncompressed_length); + } out->resize(zip_entry.uncompressed_length); fprintf(stderr, "extracting %s (%zu MB) to RAM...\n", entry_name.c_str(), @@ -638,14 +641,14 @@ static void delete_fbemarker_tmpdir(const std::string& dir) { static int unzip_to_file(ZipArchiveHandle zip, const char* entry_name) { unique_fd fd(make_temporary_fd(entry_name)); - ZipEntry zip_entry; + ZipEntry64 zip_entry; if (FindEntry(zip, entry_name, &zip_entry) != 0) { fprintf(stderr, "archive does not contain '%s'\n", entry_name); errno = ENOENT; return -1; } - fprintf(stderr, "extracting %s (%" PRIu32 " MB) to disk...", entry_name, + fprintf(stderr, "extracting %s (%" PRIu64 " MB) to disk...", entry_name, zip_entry.uncompressed_length / 1024 / 1024); double start = now(); int error = ExtractEntryToFile(zip, &zip_entry, fd);