aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoris Lijssens <joris.lijssens@gmail.com>2016-06-17 10:46:58 +0200
committerTom Rini <trini@konsulko.com>2016-06-24 17:23:11 -0400
commita2cfc8d5935efd445d9f9b258383e2a42f83ef6e (patch)
treea746323ae52ed1c53f90282c3d02b5c79a399ecf /lib
parent96044745cb8c086d47215f4aa7b4defb1d1fec57 (diff)
downloadu-boot-a2cfc8d5935efd445d9f9b258383e2a42f83ef6e.zip
u-boot-a2cfc8d5935efd445d9f9b258383e2a42f83ef6e.tar.gz
u-boot-a2cfc8d5935efd445d9f9b258383e2a42f83ef6e.tar.bz2
lib/lzo: bugfix when input data is not compressed
When the input data is not compressed at all, lzo1x_decompress_safe will fail, so call memcpy() instead. Signed-off-by: Joris Lijssens <joris.lijssens@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/lzo/lzo1x_decompress.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/lzo/lzo1x_decompress.c b/lib/lzo/lzo1x_decompress.c
index ebdf10b..ccc90b8 100644
--- a/lib/lzo/lzo1x_decompress.c
+++ b/lib/lzo/lzo1x_decompress.c
@@ -98,18 +98,25 @@ int lzop_decompress(const unsigned char *src, size_t src_len,
if (dlen > remaining)
return LZO_E_OUTPUT_OVERRUN;
- /* decompress */
- tmp = dlen;
- r = lzo1x_decompress_safe((u8 *) src, slen, dst, &tmp);
+ /* When the input data is not compressed at all,
+ * lzo1x_decompress_safe will fail, so call memcpy()
+ * instead */
+ if (dlen == slen) {
+ memcpy(dst, src, slen);
+ } else {
+ /* decompress */
+ tmp = dlen;
+ r = lzo1x_decompress_safe((u8 *)src, slen, dst, &tmp);
+
+ if (r != LZO_E_OK) {
+ *dst_len = dst - start;
+ return r;
+ }
- if (r != LZO_E_OK) {
- *dst_len = dst - start;
- return r;
+ if (dlen != tmp)
+ return LZO_E_ERROR;
}
- if (dlen != tmp)
- return LZO_E_ERROR;
-
src += slen;
dst += dlen;
remaining -= dlen;