Skip to content

Commit 8cef3ce

Browse files
gregkhJiri Slaby
authored andcommitted
lz4: fix another possible overrun
commit 4148c1f upstream. 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: Jiri Slaby <jslaby@suse.cz>
1 parent 591cb1f commit 8cef3ce

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎lib/lz4/lz4_decompress.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
108108
if (length == ML_MASK) {
109109
for (; *ip == 255; length += 255)
110110
ip++;
111+
if (unlikely(length > (size_t)(length + *ip)))
112+
goto _output_error;
111113
length += *ip++;
112114
}
113115

@@ -157,7 +159,7 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
157159

158160
/* write overflow error detected */
159161
_output_error:
160-
return (int) (-(((char *)ip) - source));
162+
return -1;
161163
}
162164

163165
static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,

0 commit comments

Comments
 (0)