summaryrefslogtreecommitdiff
path: root/libs/androidfw/ZipFileRO.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2020-12-14 20:42:03 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-12-14 20:42:03 +0000
commit314863c132479b108f0ce61a5a753123cd3a15ca (patch)
tree8c2c62e7f5964b3ed503f1f2c753d0850ac70dec /libs/androidfw/ZipFileRO.cpp
parent2991744d472491889d9ba465c8f96c1022af5df0 (diff)
parenta45506e6f6619f59ce1ae94b20ad377b86966be0 (diff)
Merge changes from topic "inc-hard-am"
* changes: Revert^2 "Cache resolved theme values" Set resource id correctly when resolve fails Revert^2 "libandroidfw hardening for IncFs" idmap2: remove call to obsolete 'idmap2 verify' from valgrind.sh idmap2: remove the 'scan' command
Diffstat (limited to 'libs/androidfw/ZipFileRO.cpp')
-rw-r--r--libs/androidfw/ZipFileRO.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp
index e77ac3df474c..52e7a70521a1 100644
--- a/libs/androidfw/ZipFileRO.cpp
+++ b/libs/androidfw/ZipFileRO.cpp
@@ -233,6 +233,29 @@ FileMap* ZipFileRO::createEntryFileMap(ZipEntryRO entry) const
}
/*
+ * Create a new incfs::IncFsFileMap object that spans the data in "entry".
+ */
+std::optional<incfs::IncFsFileMap> ZipFileRO::createEntryIncFsFileMap(ZipEntryRO entry) const
+{
+ const _ZipEntryRO *zipEntry = reinterpret_cast<_ZipEntryRO*>(entry);
+ const ZipEntry& ze = zipEntry->entry;
+ int fd = GetFileDescriptor(mHandle);
+ size_t actualLen = 0;
+
+ if (ze.method == kCompressStored) {
+ actualLen = ze.uncompressed_length;
+ } else {
+ actualLen = ze.compressed_length;
+ }
+
+ incfs::IncFsFileMap newMap;
+ if (!newMap.Create(fd, ze.offset, actualLen, mFileName)) {
+ return std::nullopt;
+ }
+ return std::move(newMap);
+}
+
+/*
* Uncompress an entry, in its entirety, into the provided output buffer.
*
* This doesn't verify the data's CRC, which might be useful for