From 55ef6167a2c235bd88c7216238b2001b46795b79 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Fri, 13 Nov 2020 23:55:20 +0000 Subject: Revert "libandroidfw hardening for IncFs" Revert "Move map_ptr to incfs namspace" Revert submission 12787270 Reason for revert: b/173250495 Reverted Changes: I5cd1bc8a2:libandroidfw hardening for IncFs Ice5dbcfb2:Move map_ptr to incfs namspace I29ccdc8ed:Do not cache bag parent stack until requested I1e9e9acaa:Cache resolved theme values Change-Id: Ib90ef68339710086df41e9abe0833a542d03a74f --- libs/androidfw/ZipUtils.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'libs/androidfw/ZipUtils.cpp') diff --git a/libs/androidfw/ZipUtils.cpp b/libs/androidfw/ZipUtils.cpp index 58fc5bbbab5e..568e3b63d67f 100644 --- a/libs/androidfw/ZipUtils.cpp +++ b/libs/androidfw/ZipUtils.cpp @@ -40,7 +40,7 @@ class FileReader : public zip_archive::Reader { explicit FileReader(FILE* fp) : Reader(), mFp(fp), mCurrentOffset(0) { } - bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const override { + bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const { // Data is usually requested sequentially, so this helps avoid pointless // fseeks every time we perform a read. There's an impedence mismatch // here because the original API was designed around pread and pwrite. @@ -71,7 +71,7 @@ class FdReader : public zip_archive::Reader { explicit FdReader(int fd) : mFd(fd) { } - bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const override { + bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const { return android::base::ReadFullyAtOffset(mFd, buf, len, offset); } @@ -81,27 +81,22 @@ class FdReader : public zip_archive::Reader { class BufferReader : public zip_archive::Reader { public: - BufferReader(incfs::map_ptr input, size_t inputSize) : Reader(), - mInput(input.convert()), + BufferReader(const void* input, size_t inputSize) : Reader(), + mInput(reinterpret_cast(input)), mInputSize(inputSize) { } - bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const override { + bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const { if (mInputSize < len || offset > mInputSize - len) { return false; } - const incfs::map_ptr pos = mInput.offset(offset); - if (!pos.verify(len)) { - return false; - } - - memcpy(buf, pos.unsafe_ptr(), len); + memcpy(buf, mInput + offset, len); return true; } private: - const incfs::map_ptr mInput; + const uint8_t* mInput; const size_t mInputSize; }; @@ -143,7 +138,7 @@ class BufferWriter : public zip_archive::Writer { return (zip_archive::Inflate(reader, compressedLen, uncompressedLen, &writer, nullptr) == 0); } -/*static*/ bool ZipUtils::inflateToBuffer(incfs::map_ptr in, void* buf, +/*static*/ bool ZipUtils::inflateToBuffer(const void* in, void* buf, long uncompressedLen, long compressedLen) { BufferReader reader(in, compressedLen); -- cgit v1.2.3-59-g8ed1b