summaryrefslogtreecommitdiff
path: root/libs/androidfw/ZipUtils.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2020-11-13 23:55:20 +0000
committerRyan Mitchell <rtmitchell@google.com>2020-11-13 23:55:20 +0000
commit55ef6167a2c235bd88c7216238b2001b46795b79 (patch)
tree5a63ff5e6b8a0ade4ce5aa2c4d663d62a7d993d9 /libs/androidfw/ZipUtils.cpp
parent6ca48473e533a8b89abac6294a0bb8130b8c8c89 (diff)
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
Diffstat (limited to 'libs/androidfw/ZipUtils.cpp')
-rw-r--r--libs/androidfw/ZipUtils.cpp21
1 files changed, 8 insertions, 13 deletions
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<void> input, size_t inputSize) : Reader(),
- mInput(input.convert<uint8_t>()),
+ BufferReader(const void* input, size_t inputSize) : Reader(),
+ mInput(reinterpret_cast<const uint8_t*>(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<uint8_t> 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<uint8_t> 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<void> in, void* buf,
+/*static*/ bool ZipUtils::inflateToBuffer(const void* in, void* buf,
long uncompressedLen, long compressedLen)
{
BufferReader reader(in, compressedLen);