summaryrefslogtreecommitdiff
path: root/tools/ziptime/ZipEntry.cpp
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2023-01-10 22:59:40 +0000
committer Elliott Hughes <enh@google.com> 2023-01-13 00:41:38 +0000
commit04434739a2f65e1b0230fe8e7d8abd7586ed3a76 (patch)
treea295af34c44d57ac73a0de0d240ed366c2cb4f11 /tools/ziptime/ZipEntry.cpp
parente61203da9cc00d0b93f62ba4d8b04f05a2a2f4b5 (diff)
zipalign/ziptime: use ftello()/fseeko().
Even if we were shipping 64-bit Windows host tools (which we still aren't), this would still be a bug. Windows is LLP64 instead of LP64, so the long that ftell()/fseek() uses isn't big enough for a 64-bit off_t. Test: treehugger Change-Id: I4e24afe811ff9b7d5696887cc5ee92e54e4a3b76
Diffstat (limited to 'tools/ziptime/ZipEntry.cpp')
-rw-r--r--tools/ziptime/ZipEntry.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/tools/ziptime/ZipEntry.cpp b/tools/ziptime/ZipEntry.cpp
index e7b52ed0a7..c8eb377e46 100644
--- a/tools/ziptime/ZipEntry.cpp
+++ b/tools/ziptime/ZipEntry.cpp
@@ -43,19 +43,16 @@ using namespace android;
*/
status_t ZipEntry::initAndRewriteFromCDE(FILE* fp)
{
- status_t result;
- long posn;
-
/* read the CDE */
- result = mCDE.rewrite(fp);
+ status_t result = mCDE.rewrite(fp);
if (result != 0) {
LOG("mCDE.rewrite failed\n");
return result;
}
/* using the info in the CDE, go load up the LFH */
- posn = ftell(fp);
- if (fseek(fp, mCDE.mLocalHeaderRelOffset, SEEK_SET) != 0) {
+ off_t posn = ftello(fp);
+ if (fseeko(fp, mCDE.mLocalHeaderRelOffset, SEEK_SET) != 0) {
LOG("local header seek failed (%" PRIu32 ")\n",
mCDE.mLocalHeaderRelOffset);
return -1;
@@ -67,7 +64,7 @@ status_t ZipEntry::initAndRewriteFromCDE(FILE* fp)
return result;
}
- if (fseek(fp, posn, SEEK_SET) != 0)
+ if (fseeko(fp, posn, SEEK_SET) != 0)
return -1;
return 0;