Loading include/utils/ObbFile.h +4 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ public: bool readFrom(int fd); bool writeTo(const char* filename); bool writeTo(int fd); bool removeFrom(const char* filename); bool removeFrom(int fd); const char* getFileName() const { return mFileName; Loading Loading @@ -78,6 +80,8 @@ private: size_t mFileSize; size_t mFooterStart; unsigned char* mReadBuf; bool parseObbFile(int fd); Loading libs/utils/ObbFile.cpp +39 −3 Original line number Diff line number Diff line Loading @@ -156,9 +156,9 @@ bool ObbFile::parseObbFile(int fd) return false; } if (footerSize < kFooterMinSize) { LOGW("claimed footer size is too small (%08zx; minimum size is 0x%x)\n", footerSize, kFooterMinSize); if (footerSize < (kFooterMinSize - kFooterTagSize)) { LOGW("claimed footer size is too small (0x%zx; minimum size is 0x%x)\n", footerSize, kFooterMinSize - kFooterTagSize); return false; } } Loading @@ -169,6 +169,8 @@ bool ObbFile::parseObbFile(int fd) return false; } mFooterStart = fileOffset; char* scanBuf = (char*)malloc(footerSize); if (scanBuf == NULL) { LOGW("couldn't allocate scanBuf: %s\n", strerror(errno)); Loading Loading @@ -293,4 +295,38 @@ bool ObbFile::writeTo(int fd) return true; } bool ObbFile::removeFrom(const char* filename) { int fd; bool success = false; fd = ::open(filename, O_RDWR); if (fd < 0) { goto out; } success = removeFrom(fd); close(fd); out: if (!success) { LOGW("failed to remove signature from %s: %s\n", filename, strerror(errno)); } return success; } bool ObbFile::removeFrom(int fd) { if (fd < 0) { return false; } if (!readFrom(fd)) { return false; } ftruncate(fd, mFooterStart); return true; } } Loading
include/utils/ObbFile.h +4 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ public: bool readFrom(int fd); bool writeTo(const char* filename); bool writeTo(int fd); bool removeFrom(const char* filename); bool removeFrom(int fd); const char* getFileName() const { return mFileName; Loading Loading @@ -78,6 +80,8 @@ private: size_t mFileSize; size_t mFooterStart; unsigned char* mReadBuf; bool parseObbFile(int fd); Loading
libs/utils/ObbFile.cpp +39 −3 Original line number Diff line number Diff line Loading @@ -156,9 +156,9 @@ bool ObbFile::parseObbFile(int fd) return false; } if (footerSize < kFooterMinSize) { LOGW("claimed footer size is too small (%08zx; minimum size is 0x%x)\n", footerSize, kFooterMinSize); if (footerSize < (kFooterMinSize - kFooterTagSize)) { LOGW("claimed footer size is too small (0x%zx; minimum size is 0x%x)\n", footerSize, kFooterMinSize - kFooterTagSize); return false; } } Loading @@ -169,6 +169,8 @@ bool ObbFile::parseObbFile(int fd) return false; } mFooterStart = fileOffset; char* scanBuf = (char*)malloc(footerSize); if (scanBuf == NULL) { LOGW("couldn't allocate scanBuf: %s\n", strerror(errno)); Loading Loading @@ -293,4 +295,38 @@ bool ObbFile::writeTo(int fd) return true; } bool ObbFile::removeFrom(const char* filename) { int fd; bool success = false; fd = ::open(filename, O_RDWR); if (fd < 0) { goto out; } success = removeFrom(fd); close(fd); out: if (!success) { LOGW("failed to remove signature from %s: %s\n", filename, strerror(errno)); } return success; } bool ObbFile::removeFrom(int fd) { if (fd < 0) { return false; } if (!readFrom(fd)) { return false; } ftruncate(fd, mFooterStart); return true; } }