Skip to content

Commit

Permalink
Fix a couple buffer overflows
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiangreffrath committed Jun 10, 2019
1 parent a8dc3f8 commit 942c3e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libfaad/bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ void faad_resetbits(bitfile *ld, int bits)
int words = bits >> 5;
int remainder = bits & 0x1F;

ld->bytes_left = ld->buffer_size - words*4;
if (ld->buffer_size < words * 4)
ld->bytes_left = 0;
else
ld->bytes_left = ld->buffer_size - words*4;

if (ld->bytes_left >= 4)
{
Expand Down
2 changes: 2 additions & 0 deletions libfaad/syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,8 @@ static uint8_t excluded_channels(bitfile *ld, drc_info *drc)
while ((drc->additional_excluded_chns[n-1] = faad_get1bit(ld
DEBUGVAR(1,104,"excluded_channels(): additional_excluded_chns"))) == 1)
{
if (i >= MAX_CHANNELS - num_excl_chan - 7)
return n;
for (i = num_excl_chan; i < num_excl_chan+7; i++)
{
drc->exclude_mask[i] = faad_get1bit(ld
Expand Down

0 comments on commit 942c3e0

Please sign in to comment.