aboutsummaryrefslogtreecommitdiffstats
path: root/lib/lz4
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-24 16:59:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-27 14:21:07 -0400
commit4148c1f67abf823099b2d7db6851e4aea407f5ee (patch)
tree1c7a40284294cc86f508fb8fa3461d1bb1223d42 /lib/lz4
parent206204a1162b995e2185275167b22468c00d6b36 (diff)
lz4: fix another possible overrun
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> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/lz4')
-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 99a03acb7d47..b74da447e81e 100644
--- a/lib/lz4/lz4_decompress.c
+++ b/lib/lz4/lz4_decompress.c
@@ -108,6 +108,8 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
108 if (length == ML_MASK) { 108 if (length == ML_MASK) {
109 for (; *ip == 255; length += 255) 109 for (; *ip == 255; length += 255)
110 ip++; 110 ip++;
111 if (unlikely(length > (size_t)(length + *ip)))
112 goto _output_error;
111 length += *ip++; 113 length += *ip++;
112 } 114 }
113 115
@@ -157,7 +159,7 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
157 159
158 /* write overflow error detected */ 160 /* write overflow error detected */
159_output_error: 161_output_error:
160 return (int) (-(((char *)ip) - source)); 162 return -1;
161} 163}
162 164
163static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, 165static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,