Merge "Fix: full ota package larger than 2GB fails to upgrade"

am: 867e60d

* commit '867e60db16d2ec687a12e525cf26f203da8396b2':
  Fix: full ota package larger than 2GB fails to upgrade
This commit is contained in:
caozhiyuan
2016-03-21 19:15:49 +00:00
committed by android-build-merger
2 changed files with 14 additions and 12 deletions
+9 -7
View File
@@ -91,7 +91,7 @@ enum {
static void dumpEntry(const ZipEntry* pEntry) static void dumpEntry(const ZipEntry* pEntry)
{ {
LOGI(" %p '%.*s'\n", pEntry->fileName,pEntry->fileNameLen,pEntry->fileName); LOGI(" %p '%.*s'\n", pEntry->fileName,pEntry->fileNameLen,pEntry->fileName);
LOGI(" off=%ld comp=%ld uncomp=%ld how=%d\n", pEntry->offset, LOGI(" off=%u comp=%u uncomp=%u how=%d\n", pEntry->offset,
pEntry->compLen, pEntry->uncompLen, pEntry->compression); pEntry->compLen, pEntry->uncompLen, pEntry->compression);
} }
#endif #endif
@@ -505,7 +505,8 @@ static bool processDeflatedEntry(const ZipArchive *pArchive,
const ZipEntry *pEntry, ProcessZipEntryContentsFunction processFunction, const ZipEntry *pEntry, ProcessZipEntryContentsFunction processFunction,
void *cookie) void *cookie)
{ {
long result = -1; bool success = false;
unsigned long totalOut = 0;
unsigned char procBuf[32 * 1024]; unsigned char procBuf[32 * 1024];
z_stream zstream; z_stream zstream;
int zerr; int zerr;
@@ -569,16 +570,17 @@ static bool processDeflatedEntry(const ZipArchive *pArchive,
assert(zerr == Z_STREAM_END); /* other errors should've been caught */ assert(zerr == Z_STREAM_END); /* other errors should've been caught */
// success! // success!
result = zstream.total_out; totalOut = zstream.total_out;
success = true;
z_bail: z_bail:
inflateEnd(&zstream); /* free up any allocated structures */ inflateEnd(&zstream); /* free up any allocated structures */
bail: bail:
if (result != pEntry->uncompLen) { if (totalOut != pEntry->uncompLen) {
if (result != -1) // error already shown? if (success) { // error already shown?
LOGW("Size mismatch on inflated file (%ld vs %ld)\n", LOGW("Size mismatch on inflated file (%lu vs %u)\n", totalOut, pEntry->uncompLen);
result, pEntry->uncompLen); }
return false; return false;
} }
return true; return true;
+5 -5
View File
@@ -32,9 +32,9 @@ extern "C" {
typedef struct ZipEntry { typedef struct ZipEntry {
unsigned int fileNameLen; unsigned int fileNameLen;
const char* fileName; // not null-terminated const char* fileName; // not null-terminated
long offset; uint32_t offset;
long compLen; uint32_t compLen;
long uncompLen; uint32_t uncompLen;
int compression; int compression;
long modTime; long modTime;
long crc32; long crc32;
@@ -85,10 +85,10 @@ void mzCloseZipArchive(ZipArchive* pArchive);
const ZipEntry* mzFindZipEntry(const ZipArchive* pArchive, const ZipEntry* mzFindZipEntry(const ZipArchive* pArchive,
const char* entryName); const char* entryName);
INLINE long mzGetZipEntryOffset(const ZipEntry* pEntry) { INLINE uint32_t mzGetZipEntryOffset(const ZipEntry* pEntry) {
return pEntry->offset; return pEntry->offset;
} }
INLINE long mzGetZipEntryUncompLen(const ZipEntry* pEntry) { INLINE uint32_t mzGetZipEntryUncompLen(const ZipEntry* pEntry) {
return pEntry->uncompLen; return pEntry->uncompLen;
} }