Skip to content

Commit

Permalink
fix potential decompressor crash with Negative size passed to memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
inikep committed Jun 23, 2018
1 parent 6a1ed71 commit 02491c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/lizard_decompress_liz.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ FORCE_INLINE int Lizard_decompress_LIZv1(
/* last literals */
length = ctx->literalsEnd - ctx->literalsPtr;
cpy = op + length;
if ((ctx->literalsPtr+length != iend) || (cpy > oend)) { LIZARD_LOG_DECOMPRESS_LIZv1("14"); goto _output_error; } /* Error : input must be consumed */
if ((length < 0) || (ctx->literalsPtr+length != iend) || (cpy > oend)) { LIZARD_LOG_DECOMPRESS_LIZv1("14"); goto _output_error; } /* Error : input must be consumed */
memcpy(op, ctx->literalsPtr, length);
ctx->literalsPtr += length;
op += length;
Expand Down
2 changes: 1 addition & 1 deletion lib/lizard_decompress_lz4.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ FORCE_INLINE int Lizard_decompress_LZ4(
/* last literals */
length = ctx->literalsEnd - ctx->literalsPtr;
cpy = op + length;
if ((ctx->literalsPtr+length != iend) || (cpy > oend)) { LIZARD_LOG_DECOMPRESS_LZ4("9"); goto _output_error; } /* Error : input must be consumed */
if ((length < 0) || (ctx->literalsPtr+length != iend) || (cpy > oend)) { LIZARD_LOG_DECOMPRESS_LZ4("9"); goto _output_error; } /* Error : input must be consumed */
memcpy(op, ctx->literalsPtr, length);
ctx->literalsPtr += length;
op += length;
Expand Down

0 comments on commit 02491c7

Please sign in to comment.