Skip to content

Commit

Permalink
4936 lz4 could theoretically overflow a pointer with a certain input
Browse files Browse the repository at this point in the history
Reviewed by: Saso Kiselkov <[email protected]>
Reviewed by: Keith Wesolowski <[email protected]>
Approved by: Gordon Ross <[email protected]>
  • Loading branch information
Dan McDonald committed Jun 26, 2014
1 parent 7802d7b commit 58d0718
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions usr/src/grub/grub-0.97/stage2/zfs_lz4.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ LZ4_uncompress_unknownOutputSize(const char *source,
}
/* copy literals */
cpy = op + length;
/* CORNER-CASE: cpy might overflow. */
if (cpy < op)
goto _output_error; /* cpy was overflowed, bail! */
if ((cpy > oend - COPYLENGTH) ||
(ip + length > iend - COPYLENGTH)) {
if (cpy > oend)
Expand Down
6 changes: 6 additions & 0 deletions usr/src/uts/common/fs/zfs/lz4.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,9 @@ real_LZ4_uncompress(const char *source, char *dest, int osize)
}
/* copy literals */
cpy = op + length;
/* CORNER-CASE: cpy might overflow. */
if (cpy < op)
goto _output_error; /* cpy was overflowed, bail! */
if unlikely(cpy > oend - COPYLENGTH) {
if (cpy != oend)
/* Error: we must necessarily stand at EOF */
Expand Down Expand Up @@ -1075,6 +1078,9 @@ LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize,
}
/* copy literals */
cpy = op + length;
/* CORNER-CASE: cpy might overflow. */
if (cpy < op)
goto _output_error; /* cpy was overflowed, bail! */
if ((cpy > oend - COPYLENGTH) ||
(ip + length > iend - COPYLENGTH)) {
if (cpy > oend)
Expand Down

0 comments on commit 58d0718

Please sign in to comment.