Skip to content

Commit

Permalink
avcodec/jpeg2000dec: prevent out of array accesses in pixel addressing
Browse files Browse the repository at this point in the history
Fixes Ticket2921

Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Oct 13, 2013
1 parent e54f451 commit fe448cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libavcodec/jpeg2000dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1278,12 +1278,12 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,


y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = picture->data[plane] + y * picture->linesize[plane];
line = picture->data[plane] + y / s->cdy[compno] * picture->linesize[plane];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint8_t *dst;

x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = line + x * pixelsize + compno*!planar;
dst = line + x / s->cdx[compno] * pixelsize + compno*!planar;

if (codsty->transform == FF_DWT97) {
for (; x < w; x += s->cdx[compno]) {
Expand Down Expand Up @@ -1324,12 +1324,12 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1);

y = tile->comp[compno].coord[1][0] - s->image_offset_y;
linel = (uint16_t *)picture->data[plane] + y * (picture->linesize[plane] >> 1);
linel = (uint16_t *)picture->data[plane] + y / s->cdy[compno] * (picture->linesize[plane] >> 1);
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint16_t *dst;

x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = linel + (x * pixelsize + compno*!planar);
dst = linel + (x / s->cdx[compno] * pixelsize + compno*!planar);
if (codsty->transform == FF_DWT97) {
for (; x < w; x += s-> cdx[compno]) {
int val = lrintf(*datap) + (1 << (cbps - 1));
Expand Down

0 comments on commit fe448cd

Please sign in to comment.