Skip to content

Commit

Permalink
lz4: fix another possible overrun
Browse files Browse the repository at this point in the history
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" <[email protected]>
Reported-by: Willy Tarreau <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed Jun 27, 2014
1 parent 206204a commit 4148c1f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/lz4/lz4_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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++;
}

Expand Down Expand Up @@ -157,7 +159,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,
Expand Down

0 comments on commit 4148c1f

Please sign in to comment.