diff options
author | David Riley <davidriley@google.com> | 2016-01-04 19:07:54 +0100 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-01-04 19:07:54 +0100 |
commit | 085fc1361f9b408a84f8330ed38783a8c18f6ba4 (patch) | |
tree | d7bfc0e1f03e86641063ac8767f25863dfc3cb3e | |
parent | Merge "res: Embed FPS into icon_installing.png." am: 29b0fbe160 (diff) | |
parent | Merge "imgdiff: skip spurious gzip headers in image files" (diff) | |
download | android_bootable_recovery-085fc1361f9b408a84f8330ed38783a8c18f6ba4.tar android_bootable_recovery-085fc1361f9b408a84f8330ed38783a8c18f6ba4.tar.gz android_bootable_recovery-085fc1361f9b408a84f8330ed38783a8c18f6ba4.tar.bz2 android_bootable_recovery-085fc1361f9b408a84f8330ed38783a8c18f6ba4.tar.lz android_bootable_recovery-085fc1361f9b408a84f8330ed38783a8c18f6ba4.tar.xz android_bootable_recovery-085fc1361f9b408a84f8330ed38783a8c18f6ba4.tar.zst android_bootable_recovery-085fc1361f9b408a84f8330ed38783a8c18f6ba4.zip |
Diffstat (limited to '')
-rw-r--r-- | applypatch/imgdiff.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp index 50cabbe6b..f22502e38 100644 --- a/applypatch/imgdiff.cpp +++ b/applypatch/imgdiff.cpp @@ -407,6 +407,7 @@ unsigned char* ReadImage(const char* filename, while (pos < sz) { unsigned char* p = img+pos; + bool processed_deflate = false; if (sz - pos >= 4 && p[0] == 0x1f && p[1] == 0x8b && p[2] == 0x08 && // deflate compression @@ -460,18 +461,24 @@ unsigned char* ReadImage(const char* filename, strm.next_out = curr->data + curr->len; ret = inflate(&strm, Z_NO_FLUSH); if (ret < 0) { - printf("Error: inflate failed [%s] at file offset [%zu]\n" - "imgdiff only supports gzip kernel compression," - " did you try CONFIG_KERNEL_LZO?\n", - strm.msg, chunk_offset); - free(img); - return NULL; + if (!processed_deflate) { + // This is the first chunk, assume that it's just a spurious + // gzip header instead of a real one. + break; + } + printf("Error: inflate failed [%s] at file offset [%zu]\n" + "imgdiff only supports gzip kernel compression," + " did you try CONFIG_KERNEL_LZO?\n", + strm.msg, chunk_offset); + free(img); + return NULL; } curr->len = allocated - strm.avail_out; if (strm.avail_out == 0) { allocated *= 2; curr->data = reinterpret_cast<unsigned char*>(realloc(curr->data, allocated)); } + processed_deflate = true; } while (ret != Z_STREAM_END); curr->deflate_len = sz - strm.avail_in - pos; |