diff options
author | David S. Miller <davem@davemloft.net> | 2019-04-09 08:39:36 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-09 08:39:36 +0200 |
commit | 310655b07ae8ef0b8fdb641b610ded2052215664 (patch) | |
tree | d9b7a500ef21a087a337e1f1bb9218000cf1c03d /lib/lzo/lzo1x_compress.c | |
parent | ethtool: thunder_bgx: use ethtool.h constants for speed and duplex (diff) | |
parent | Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (diff) | |
download | linux-310655b07ae8ef0b8fdb641b610ded2052215664.tar.xz linux-310655b07ae8ef0b8fdb641b610ded2052215664.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'lib/lzo/lzo1x_compress.c')
-rw-r--r-- | lib/lzo/lzo1x_compress.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/lzo/lzo1x_compress.c b/lib/lzo/lzo1x_compress.c index 4525fb094844..a8ede77afe0d 100644 --- a/lib/lzo/lzo1x_compress.c +++ b/lib/lzo/lzo1x_compress.c @@ -291,13 +291,14 @@ int lzogeneric1x_1_compress(const unsigned char *in, size_t in_len, { const unsigned char *ip = in; unsigned char *op = out; + unsigned char *data_start; size_t l = in_len; size_t t = 0; signed char state_offset = -2; unsigned int m4_max_offset; - // LZO v0 will never write 17 as first byte, - // so this is used to version the bitstream + // LZO v0 will never write 17 as first byte (except for zero-length + // input), so this is used to version the bitstream if (bitstream_version > 0) { *op++ = 17; *op++ = bitstream_version; @@ -306,6 +307,8 @@ int lzogeneric1x_1_compress(const unsigned char *in, size_t in_len, m4_max_offset = M4_MAX_OFFSET_V0; } + data_start = op; + while (l > 20) { size_t ll = l <= (m4_max_offset + 1) ? l : (m4_max_offset + 1); uintptr_t ll_end = (uintptr_t) ip + ll; @@ -324,7 +327,7 @@ int lzogeneric1x_1_compress(const unsigned char *in, size_t in_len, if (t > 0) { const unsigned char *ii = in + in_len - t; - if (op == out && t <= 238) { + if (op == data_start && t <= 238) { *op++ = (17 + t); } else if (t <= 3) { op[state_offset] |= t; |