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>
This commit is contained in:
Joris Lijssens 2016-06-17 10:46:58 +02:00 committed by Tom Rini
parent 96044745cb
commit a2cfc8d593

View File

@ -98,6 +98,12 @@ int lzop_decompress(const unsigned char *src, size_t src_len,
if (dlen > remaining)
return LZO_E_OUTPUT_OVERRUN;
/* 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);
@ -109,6 +115,7 @@ int lzop_decompress(const unsigned char *src, size_t src_len,
if (dlen != tmp)
return LZO_E_ERROR;
}
src += slen;
dst += dlen;