diff options
Diffstat (limited to 'applypatch')
-rw-r--r-- | applypatch/bspatch.c | 1 | ||||
-rw-r--r-- | applypatch/imgdiff.c | 9 | ||||
-rw-r--r-- | applypatch/imgpatch.c | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/applypatch/bspatch.c b/applypatch/bspatch.c index b34ec2a88..b57760eda 100644 --- a/applypatch/bspatch.c +++ b/applypatch/bspatch.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <sys/stat.h> #include <errno.h> +#include <malloc.h> #include <unistd.h> #include <string.h> diff --git a/applypatch/imgdiff.c b/applypatch/imgdiff.c index 05c4f250f..3bac8be91 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; diff --git a/applypatch/imgpatch.c b/applypatch/imgpatch.c index 33c448762..09b0a7397 100644 --- a/applypatch/imgpatch.c +++ b/applypatch/imgpatch.c @@ -21,6 +21,7 @@ #include <sys/cdefs.h> #include <sys/stat.h> #include <errno.h> +#include <malloc.h> #include <unistd.h> #include <string.h> |