summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJiamin Ma <jiamin.ma@amlogic.com>2019-04-01 16:54:50 +0800
committerDongjin Kim <tobetter@gmail.com>2019-05-16 13:19:38 +0900
commitb573105a2ddda09b36e877ef6f996a0f95154347 (patch)
treeda3159edf6b4997cea7ffaa82e0737434aaf21fc /lib
parentc76297d55eed82e1be76fb86eefb57977c26db3e (diff)
downloadu-boot-odroid-c1-b573105a2ddda09b36e877ef6f996a0f95154347.tar.gz
lzo: fix failing to decompress some lzo images [1/1]
PD#TV-3883 Problem: When compressing an image in lzo format, the original image is devided into chunks with 256KB, which are compressed each. In some cases, one chunk may already be lzo compressed, and we should not try to decompress such a chunk Solution: Do not decompress the chunk which is lzo compressed by default Verify: X301 Change-Id: I17979f6ff3a514769b52b279593cd490920ad46f Signed-off-by: Jiamin Ma <jiamin.ma@amlogic.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/lzo/lzo1x_decompress.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/lzo/lzo1x_decompress.c b/lib/lzo/lzo1x_decompress.c
index 35f3793f31..9055ee4d55 100644
--- a/lib/lzo/lzo1x_decompress.c
+++ b/lib/lzo/lzo1x_decompress.c
@@ -99,14 +99,22 @@ int lzop_decompress(const unsigned char *src, size_t src_len,
return LZO_E_OUTPUT_OVERRUN;
/* decompress */
- tmp = dlen;
- r = lzo1x_decompress_safe((u8 *) src, slen, dst, &tmp);
-
- if (r != LZO_E_OK)
- return r;
-
- if (dlen != tmp)
- return LZO_E_ERROR;
+ if (slen < dlen) {
+ tmp = dlen;
+ r = lzo1x_decompress_safe((u8 *)src, slen, dst, &tmp);
+
+ if (r != LZO_E_OK)
+ return r;
+
+ if (dlen != tmp)
+ return LZO_E_ERROR;
+ } else {
+ int cnt = 0;
+ while (cnt < slen) {
+ dst[cnt] = src[cnt];
+ cnt += 1;
+ }
+ }
src += slen;
dst += dlen;