Commit 8962da9e authored by Hendrik Leppkes's avatar Hendrik Leppkes Committed by Michael Niedermayer

rawdec: allocate a buffer in the appropriate size in the copy case.

Otherwise the created buffer can be smaller than buf_size, which results
in buffer overreads if the original image has extra padding on every line.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 359af6a7
...@@ -190,7 +190,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -190,7 +190,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
return res; return res;
if (need_copy) if (need_copy)
frame->buf[0] = av_buffer_alloc(context->frame_size); frame->buf[0] = av_buffer_alloc(FFMAX(context->frame_size, buf_size));
else else
frame->buf[0] = av_buffer_ref(avpkt->buf); frame->buf[0] = av_buffer_ref(avpkt->buf);
if (!frame->buf[0]) if (!frame->buf[0])
...@@ -219,7 +219,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -219,7 +219,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
} }
buf = dst; buf = dst;
} else if (need_copy) { } else if (need_copy) {
memcpy(frame->buf[0]->data, buf, FFMIN(buf_size, context->frame_size)); memcpy(frame->buf[0]->data, buf, buf_size);
buf = frame->buf[0]->data; buf = frame->buf[0]->data;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment