Skip to content

Commit

Permalink
crypto: lz4,lz4hc - fix decompression
Browse files Browse the repository at this point in the history
The lz4 library has two functions for decompression, with slightly
different signatures and behaviour. The lz4_decompress_crypto() function
seemed to be using the one that assumes that the decompressed length is
known in advance.

This patch switches to the other decompression function and makes sure
that the length of the decompressed output is properly returned to the
caller.

The same issue was present in the lz4hc algorithm.

Coincidentally, this change also makes very basic lz4 and lz4hc
compression tests in testmgr pass.

Signed-off-by: KOVACS Krisztian <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
kkovaacs authored and herbertx committed Aug 29, 2014
1 parent 51269ad commit d801ab2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crypto/lz4.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int lz4_decompress_crypto(struct crypto_tfm *tfm, const u8 *src,
size_t tmp_len = *dlen;
size_t __slen = slen;

err = lz4_decompress(src, &__slen, dst, tmp_len);
err = lz4_decompress_unknownoutputsize(src, __slen, dst, &tmp_len);
if (err < 0)
return -EINVAL;

Expand Down
2 changes: 1 addition & 1 deletion crypto/lz4hc.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int lz4hc_decompress_crypto(struct crypto_tfm *tfm, const u8 *src,
size_t tmp_len = *dlen;
size_t __slen = slen;

err = lz4_decompress(src, &__slen, dst, tmp_len);
err = lz4_decompress_unknownoutputsize(src, __slen, dst, &tmp_len);
if (err < 0)
return -EINVAL;

Expand Down

0 comments on commit d801ab2

Please sign in to comment.