Skip to content
Snippets Groups Projects
Commit fea714ec authored by Daniel Kang's avatar Daniel Kang Committed by Carl Eugen Hoyos
Browse files

Do not overread input buffer.

Fixes issue 2503.

Patch by Daniel Kang, daniel.d.kang at gmail

Originally committed as revision 26256 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 10d8eac9
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,7 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -55,6 +55,7 @@ static int decode_frame(AVCodecContext *avctx,
AVPacket *avpkt) AVPacket *avpkt)
{ {
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = avpkt->data + avpkt->size;
int buf_size = avpkt->size; int buf_size = avpkt->size;
DPXContext *const s = avctx->priv_data; DPXContext *const s = avctx->priv_data;
AVFrame *picture = data; AVFrame *picture = data;
...@@ -172,6 +173,10 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -172,6 +173,10 @@ static int decode_frame(AVCodecContext *avctx,
case 8: case 8:
case 12: // Treat 12-bit as 16-bit case 12: // Treat 12-bit as 16-bit
case 16: case 16:
if (source_packet_size*avctx->width*avctx->height > buf_end - buf) {
av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n");
return -1;
}
if (source_packet_size == target_packet_size) { if (source_packet_size == target_packet_size) {
for (x = 0; x < avctx->height; x++) { for (x = 0; x < avctx->height; x++) {
memcpy(ptr, buf, target_packet_size*avctx->width); memcpy(ptr, buf, target_packet_size*avctx->width);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment