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
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
using namespace android;
|
||||
|
||||
@@ -55,7 +56,7 @@ status_t ZipEntry::initAndRewriteFromCDE(FILE* fp)
|
||||
/* using the info in the CDE, go load up the LFH */
|
||||
posn = ftell(fp);
|
||||
if (fseek(fp, mCDE.mLocalHeaderRelOffset, SEEK_SET) != 0) {
|
||||
LOG("local header seek failed (%ld)\n",
|
||||
LOG("local header seek failed (%" PRIu32 ")\n",
|
||||
mCDE.mLocalHeaderRelOffset);
|
||||
return -1;
|
||||
}
|
||||
@@ -86,7 +87,7 @@ status_t ZipEntry::initAndRewriteFromCDE(FILE* fp)
|
||||
status_t ZipEntry::LocalFileHeader::rewrite(FILE* fp)
|
||||
{
|
||||
status_t result = 0;
|
||||
unsigned char buf[kLFHLen];
|
||||
uint8_t buf[kLFHLen];
|
||||
|
||||
if (fread(buf, 1, kLFHLen, fp) != kLFHLen)
|
||||
return -1;
|
||||
@@ -124,8 +125,8 @@ status_t ZipEntry::LocalFileHeader::rewrite(FILE* fp)
|
||||
status_t ZipEntry::CentralDirEntry::rewrite(FILE* fp)
|
||||
{
|
||||
status_t result = 0;
|
||||
unsigned char buf[kCDELen];
|
||||
unsigned short fileNameLength, extraFieldLength, fileCommentLength;
|
||||
uint8_t buf[kCDELen];
|
||||
uint16_t fileNameLength, extraFieldLength, fileCommentLength;
|
||||
|
||||
if (fread(buf, 1, kCDELen, fp) != kCDELen)
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user