diff options
author | Alex Shi <alex.shi@linaro.org> | 2014-07-07 10:36:36 +0800 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2014-07-07 10:36:36 +0800 |
commit | 0f09c683deb6c649591ff38587535690078809af (patch) | |
tree | c33d5a34ad48e067bbf39234515f01d11817adfe /lib | |
parent | bab66e96641aeadf263ec443dbcc57090a664dea (diff) | |
parent | 65c0e55c16d87ab094ae512d1dc1c481be27bf21 (diff) |
Merge branch 'linux-linaro-lsk-v3.14' into linux-linaro-lsk-v3.14-android
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4/lz4_decompress.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c index b74da447e81e..7a85967060a5 100644 --- a/lib/lz4/lz4_decompress.c +++ b/lib/lz4/lz4_decompress.c @@ -192,6 +192,8 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, int s = 255; while ((ip < iend) && (s == 255)) { s = *ip++; + if (unlikely(length > (size_t)(length + s))) + goto _output_error; length += s; } } @@ -232,6 +234,8 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, if (length == ML_MASK) { while (ip < iend) { int s = *ip++; + if (unlikely(length > (size_t)(length + s))) + goto _output_error; length += s; if (s == 255) continue; @@ -284,7 +288,7 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, /* write overflow error detected */ _output_error: - return (int) (-(((char *) ip) - source)); + return -1; } int lz4_decompress(const unsigned char *src, size_t *src_len, |