summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHolger Schurig <holgerschurig@gmail.com>2014-07-01 23:22:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-07-02 08:19:45 +0200
commit9d6df5154284d5909294d7b13195ca41500ff79a (patch)
tree71faa25218a9a4c9fbeee1a2743c0befa8ee2808 /lib
parent918782bb0fbdc5c7b58f9a25411ba7ac5975122e (diff)
downloadbarebox-9d6df5154284d5909294d7b13195ca41500ff79a.tar.gz
barebox-9d6df5154284d5909294d7b13195ca41500ff79a.tar.xz
lz4: fix another possible overrun
Note: this is the same as 4148c1f67abf823099b2d7db6851e4aea407f5ee in linux-git. There is one other possible overrun in the lz4 code as implemented by Linux at this point in time (which differs from the upstream lz4 codebase, but will get synced at in a future kernel release.) As pointed out by Don, we also need to check the overflow in the data itself. While we are at it, replace the odd error return value with just a "simple" -1 value as the return value is never used for anything other than a basic "did this work or not" check. Reported-by: "Don A. Bailey" <donb@securitymouse.com> Reported-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Holger Schurig <holgerschurig@gmail.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4/lz4_decompress.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c
index 75cf08bd85..9f7bf1794a 100644
--- a/lib/lz4/lz4_decompress.c
+++ b/lib/lz4/lz4_decompress.c
@@ -109,6 +109,8 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
if (length == ML_MASK) {
for (; *ip == 255; length += 255)
ip++;
+ if (unlikely(length > (size_t)(length + *ip)))
+ goto _output_error;
length += *ip++;
}
@@ -158,7 +160,7 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
/* write overflow error detected */
_output_error:
- return (int) (-(((char *)ip) - source));
+ return -1;
}
static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,