Skip to content

Commit

Permalink
encode: protect from stack under-flow
Browse files Browse the repository at this point in the history
From GH #178 fuzzing
  • Loading branch information
rurban committed Dec 31, 2019
1 parent abab1bd commit 95cc930
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ bit_write_MC (Bit_Chain *dat, BITCODE_MC val)
if (byte[i] & 0x7f)
break;

if (byte[i] & 0x40)
if (byte[i] & 0x40 && i > 0)
i--;
byte[i] &= 0x7f;
if (negative)
Expand Down Expand Up @@ -953,7 +953,7 @@ bit_write_UMC (Bit_Chain *dat, BITCODE_UMC val)
if (byte[i] & 0x7f)
break;

if (byte[i] & 0x40)
if (byte[i] & 0x40 && i > 0)
i--;
byte[i] &= 0x7f;
for (j = 4; j >= i; j--)
Expand Down

0 comments on commit 95cc930

Please sign in to comment.