summaryrefslogtreecommitdiff
path: root/libs/androidfw/ZipUtils.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2020-04-04 20:40:28 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-04-04 20:40:28 +0000
commit289e25ee9bd0081db38c259d0e55d63d0bf6071e (patch)
tree3e3f51787c40f8a21735ae22e6739ae87ea3ee7b /libs/androidfw/ZipUtils.cpp
parent50b54f8dcd2ab141d9c134a15610fd87e4062fb0 (diff)
parenteead9e3edad20da20059f344c20ac8f1814e654f (diff)
Merge "Change the parameter type of offset in read" am: 74a5df06af am: eead9e3eda
Change-Id: Ie2996a6fc8f7d08f3f77589e439557b42f4ed56a
Diffstat (limited to 'libs/androidfw/ZipUtils.cpp')
-rw-r--r--libs/androidfw/ZipUtils.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/libs/androidfw/ZipUtils.cpp b/libs/androidfw/ZipUtils.cpp
index 5be2105fe404..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, uint32_t offset) const {
+ 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.
@@ -63,7 +63,7 @@ class FileReader : public zip_archive::Reader {
private:
FILE* mFp;
- mutable uint32_t mCurrentOffset;
+ mutable off64_t mCurrentOffset;
};
class FdReader : public zip_archive::Reader {
@@ -71,8 +71,8 @@ class FdReader : public zip_archive::Reader {
explicit FdReader(int fd) : mFd(fd) {
}
- bool ReadAtOffset(uint8_t* buf, size_t len, uint32_t offset) const {
- return android::base::ReadFullyAtOffset(mFd, buf, len, static_cast<off_t>(offset));
+ bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const {
+ return android::base::ReadFullyAtOffset(mFd, buf, len, offset);
}
private:
@@ -86,8 +86,8 @@ class BufferReader : public zip_archive::Reader {
mInputSize(inputSize) {
}
- bool ReadAtOffset(uint8_t* buf, size_t len, uint32_t offset) const {
- if (offset + len > mInputSize) {
+ bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const {
+ if (mInputSize < len || offset > mInputSize - len) {
return false;
}