From 99916f0496cfe37891d40f21a9a0e387620a8a60 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 13 Jan 2014 14:16:58 -0800 Subject: do verification and extraction on memory, not files Changes minzip and recovery's file signature verification to work on memory regions, rather than files. For packages which are regular files, install.cpp now mmap()s them into memory and then passes the mapped memory to the verifier and to the minzip library. Support for files which are raw block maps (which will be used when we have packages written to encrypted data partitions) is present but largely untested so far. Bug: 12188746 Change-Id: I12cc3e809834745a489dd9d4ceb558cbccdc3f71 --- minzip/Zip.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'minzip/Zip.h') diff --git a/minzip/Zip.h b/minzip/Zip.h index c94282827..05a2e60e0 100644 --- a/minzip/Zip.h +++ b/minzip/Zip.h @@ -46,11 +46,11 @@ typedef struct ZipEntry { * One Zip archive. Treat as opaque. */ typedef struct ZipArchive { - int fd; - unsigned int numEntries; - ZipEntry* pEntries; - HashTable* pHash; // maps file name to ZipEntry - MemMapping map; + unsigned int numEntries; + ZipEntry* pEntries; + HashTable* pHash; // maps file name to ZipEntry + unsigned char* addr; + size_t length; } ZipArchive; /* @@ -68,7 +68,7 @@ typedef struct { * On success, returns 0 and populates "pArchive". Returns nonzero errno * value on failure. */ -int mzOpenZipArchive(const char* fileName, ZipArchive* pArchive); +int mzOpenZipArchive(unsigned char* addr, size_t length, ZipArchive* pArchive); /* * Close archive, releasing resources associated with it. -- cgit v1.2.3 From a9300301ce0bddb6f46e1e1a7499c13b615713c6 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 10 Feb 2014 12:35:19 -0800 Subject: add mzGetStoredEntry function mzGetStoredEntry gives you a pointer and address to the data of a zip entry, assuming that entry is stored rather than deflated. Change-Id: Ifb39777c98d1d50475ef7de419cf28935f5f9965 --- minzip/Zip.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'minzip/Zip.h') diff --git a/minzip/Zip.h b/minzip/Zip.h index 05a2e60e0..2054b38a4 100644 --- a/minzip/Zip.h +++ b/minzip/Zip.h @@ -182,6 +182,17 @@ bool mzExtractZipEntryToFile(const ZipArchive *pArchive, bool mzExtractZipEntryToBuffer(const ZipArchive *pArchive, const ZipEntry *pEntry, unsigned char* buffer); +/* + * Return a pointer and length for a given entry. The returned region + * should be valid until pArchive is closed, and should be treated as + * read-only. + * + * Only makes sense for entries which are stored (ie, not compressed). + * No guarantees are made regarding alignment of the returned pointer. + */ +bool mzGetStoredEntry(const ZipArchive *pArchive, + const ZipEntry* pEntry, unsigned char **addr, size_t *length); + /* * Inflate all entries under zipDir to the directory specified by * targetDir, which must exist and be a writable directory. -- cgit v1.2.3