Skip to content

Commit

Permalink
Fix possible pointer underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
eustas committed Feb 4, 2016
1 parent d4f0cb9 commit 37a320d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dec/decode.c
Expand Up @@ -1714,6 +1714,10 @@ static BROTLI_INLINE BrotliResult ProcessCommandsInternal(int safe,
} else {
const uint8_t *ringbuffer_end_minus_copy_length =
s->ringbuffer_end - i;
/* Check for possible underflow and clamp the pointer to 0. */
if (PREDICT_FALSE(s->ringbuffer_end < (const uint8_t*)0 + i)) {
ringbuffer_end_minus_copy_length = 0;
}
uint8_t* copy_src = &s->ringbuffer[
(pos - s->distance_code) & s->ringbuffer_mask];
uint8_t* copy_dst = &s->ringbuffer[pos];
Expand Down

0 comments on commit 37a320d

Please sign in to comment.