diff --git a/uts/common/fs/zfs/lz4.c b/uts/common/fs/zfs/lz4.c index 40cb0711e08..656360a6f2e 100644 --- a/uts/common/fs/zfs/lz4.c +++ b/uts/common/fs/zfs/lz4.c @@ -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 */ @@ -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)