Use explicitly sized types in zipalign/ziptime
getLongLE would return a 64-bit number with the upper 32-bits set when
decoding a 32-bit number with the top bit set. Per the zip file format,
it was only expected to return a 32-bit number. Use explicitly sized
types so that we use the proper sizes and don't do any implicit
extensions.
Change-Id: I5a4304dc99ce5f8f17284d4ca3094ae115207a1e
diff --git a/tools/zipalign/ZipFile.h b/tools/zipalign/ZipFile.h
index b99cda5..b0bafe9 100644
--- a/tools/zipalign/ZipFile.h
+++ b/tools/zipalign/ZipFile.h
@@ -194,18 +194,18 @@
delete[] mComment;
}
- status_t readBuf(const unsigned char* buf, int len);
+ status_t readBuf(const uint8_t* buf, int len);
status_t write(FILE* fp);
- //unsigned long mSignature;
- unsigned short mDiskNumber;
- unsigned short mDiskWithCentralDir;
- unsigned short mNumEntries;
- unsigned short mTotalNumEntries;
- unsigned long mCentralDirSize;
- unsigned long mCentralDirOffset; // offset from first disk
- unsigned short mCommentLen;
- unsigned char* mComment;
+ //uint32_t mSignature;
+ uint16_t mDiskNumber;
+ uint16_t mDiskWithCentralDir;
+ uint16_t mNumEntries;
+ uint16_t mTotalNumEntries;
+ uint32_t mCentralDirSize;
+ uint32_t mCentralDirOffset; // offset from first disk
+ uint16_t mCommentLen;
+ uint8_t* mComment;
enum {
kSignature = 0x06054b50,
@@ -235,18 +235,18 @@
ZipEntry** ppEntry);
/* copy all of "srcFp" into "dstFp" */
- status_t copyFpToFp(FILE* dstFp, FILE* srcFp, unsigned long* pCRC32);
+ status_t copyFpToFp(FILE* dstFp, FILE* srcFp, uint32_t* pCRC32);
/* copy all of "data" into "dstFp" */
status_t copyDataToFp(FILE* dstFp,
- const void* data, size_t size, unsigned long* pCRC32);
+ const void* data, size_t size, uint32_t* pCRC32);
/* copy some of "srcFp" into "dstFp" */
status_t copyPartialFpToFp(FILE* dstFp, FILE* srcFp, long length,
- unsigned long* pCRC32);
+ uint32_t* pCRC32);
/* like memmove(), but on parts of a single file */
status_t filemove(FILE* fp, off_t dest, off_t src, size_t n);
/* compress all of "srcFp" into "dstFp", using Deflate */
status_t compressFpToFp(FILE* dstFp, FILE* srcFp,
- const void* data, size_t size, unsigned long* pCRC32);
+ const void* data, size_t size, uint32_t* pCRC32);
/* get modification date from a file descriptor */
time_t getModTime(int fd);