diff options
author | Johan Redestig <johan.redestig@sonymobile.com> | 2015-04-14 21:20:06 +0200 |
---|---|---|
committer | Johan Redestig <johan.redestig@sonymobile.com> | 2015-04-15 13:09:54 +0200 |
commit | c68bd34dc8d43f685c1f304a6cd9917c18c690aa (patch) | |
tree | dfbce3d59fd43cbf786563e38c1cc9b6996485da /applypatch/imgdiff.c | |
parent | 17b032e159779886f0151641a9aad5003debdce2 (diff) | |
download | bootable_recovery-c68bd34dc8d43f685c1f304a6cd9917c18c690aa.zip bootable_recovery-c68bd34dc8d43f685c1f304a6cd9917c18c690aa.tar.gz bootable_recovery-c68bd34dc8d43f685c1f304a6cd9917c18c690aa.tar.bz2 |
imgdiff: Avoid infinite loop if inflate fails
Break out of the loop if inflate returns an error
and print some details.
Change-Id: Ie157cf943291b1a26f4523b17691dfcefbc881dc
Diffstat (limited to 'applypatch/imgdiff.c')
-rw-r--r-- | applypatch/imgdiff.c | 9 |
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; |