aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-04-16 21:39:52 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-16 21:39:52 +0000
commit9ac3dffe180591661eaeef05803b2c7572ec4a17 (patch)
tree26ce1b3206ceb0dcf4d2cb684dcb017778caef2c
parenta441133871b4ad361c3c873b2b2faca500b2afb8 (diff)
parent51f42b2d20349490c62b9187bde317f25765e9b3 (diff)
downloadbootable_recovery-9ac3dffe180591661eaeef05803b2c7572ec4a17.zip
bootable_recovery-9ac3dffe180591661eaeef05803b2c7572ec4a17.tar.gz
bootable_recovery-9ac3dffe180591661eaeef05803b2c7572ec4a17.tar.bz2
am 51f42b2d: am 4381767a: Merge "imgdiff: Avoid infinite loop if inflate fails"
* commit '51f42b2d20349490c62b9187bde317f25765e9b3': imgdiff: Avoid infinite loop if inflate fails
-rw-r--r--applypatch/imgdiff.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/applypatch/imgdiff.c b/applypatch/imgdiff.c
index 05c4f25..3bac8be 100644
--- a/applypatch/imgdiff.c
+++ b/applypatch/imgdiff.c
@@ -408,6 +408,7 @@ unsigned char* ReadImage(const char* filename,
p[2] == 0x08 && // deflate compression
p[3] == 0x00) { // no header flags
// 'pos' is the offset of the start of a gzip chunk.
+ size_t chunk_offset = pos;
*num_chunks += 3;
*chunks = realloc(*chunks, *num_chunks * sizeof(ImageChunk));
@@ -453,6 +454,14 @@ unsigned char* ReadImage(const char* filename,
strm.avail_out = allocated - curr->len;
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;
+ }
curr->len = allocated - strm.avail_out;
if (strm.avail_out == 0) {
allocated *= 2;