diff options
author | 2020-11-13 00:05:40 +0000 | |
---|---|---|
committer | 2020-11-13 00:05:40 +0000 | |
commit | c234812e275368f47d798112e1de49a8aad99753 (patch) | |
tree | 2c029a88ba773fa77936dc89ccd4f6328e2ece07 /libs/androidfw/ZipFileRO.cpp | |
parent | 8f8eaec80190bc4a35851b9efbef412dd63efb70 (diff) | |
parent | 5602dc9374934a42964e0f57faa3c0aad43003e1 (diff) |
Merge changes from topic "libaw-hardening"
* changes:
Do not cache bag parent stack until requested
Cache resolved theme values
libandroidfw hardening for IncFs
Diffstat (limited to 'libs/androidfw/ZipFileRO.cpp')
-rw-r--r-- | libs/androidfw/ZipFileRO.cpp | 23 |
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 |