]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
lib/lzo: bugfix when input data is not compressed
authorJoris Lijssens <joris.lijssens@gmail.com>
Fri, 17 Jun 2016 08:46:58 +0000 (10:46 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 24 Jun 2016 21:23:11 +0000 (17:23 -0400)
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>
lib/lzo/lzo1x_decompress.c

index ebdf10b988de5964bb7769f2433ab91d8d99bffa..ccc90b8ee53fe8097d26f20d31b34dface2413b1 100644 (file)
@@ -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;