summaryrefslogtreecommitdiff
path: root/lib/lzo/lzo1x_decompress_safe.c
diff options
context:
space:
mode:
authorDave Rodgman <dave.rodgman@arm.com>2019-04-06 04:38:58 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2019-04-06 05:02:30 +0300
commitb11ed18efa8f3dc58b259b812588317b765b1cfc (patch)
treef98183968067ec487a0fd4e732d3fa7ac7ff29cf /lib/lzo/lzo1x_decompress_safe.c
parent6147e136ff5071609b54f18982dea87706288e21 (diff)
downloadlinux-b11ed18efa8f3dc58b259b812588317b765b1cfc.tar.xz
lib/lzo: fix bugs for very short or empty input
For very short input data (0 - 1 bytes), lzo-rle was not behaving correctly. Fix this behaviour and update documentation accordingly. For zero-length input, lzo v0 outputs an end-of-stream marker only, which was misinterpreted by lzo-rle as a bitstream version number. Ensure bitstream versions > 0 require a minimum stream length of 5. Also fixes a bug in handling the tail for very short inputs when a bitstream version is present. Link: http://lkml.kernel.org/r/20190326165857.34613-1-dave.rodgman@arm.com Signed-off-by: Dave Rodgman <dave.rodgman@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/lzo/lzo1x_decompress_safe.c')
-rw-r--r--lib/lzo/lzo1x_decompress_safe.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/lzo/lzo1x_decompress_safe.c b/lib/lzo/lzo1x_decompress_safe.c
index 6d2600ea3b55..9e07e9ef1aad 100644
--- a/lib/lzo/lzo1x_decompress_safe.c
+++ b/lib/lzo/lzo1x_decompress_safe.c
@@ -54,11 +54,9 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
if (unlikely(in_len < 3))
goto input_overrun;
- if (likely(*ip == 17)) {
+ if (likely(in_len >= 5) && likely(*ip == 17)) {
bitstream_version = ip[1];
ip += 2;
- if (unlikely(in_len < 5))
- goto input_overrun;
} else {
bitstream_version = 0;
}