Commit faa5a218 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/pafvideo: Check packet size and frame code before ff_reget_buffer()

Fixes 1745/clusterfuzz-testcase-minimized-6160693365571584
Fixes: Timeout

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 136ce8ba
...@@ -267,12 +267,20 @@ static int paf_video_decode(AVCodecContext *avctx, void *data, ...@@ -267,12 +267,20 @@ static int paf_video_decode(AVCodecContext *avctx, void *data,
uint8_t code, *dst, *end; uint8_t code, *dst, *end;
int i, frame, ret; int i, frame, ret;
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) if (pkt->size < 2)
return ret; return AVERROR_INVALIDDATA;
bytestream2_init(&c->gb, pkt->data, pkt->size); bytestream2_init(&c->gb, pkt->data, pkt->size);
code = bytestream2_get_byte(&c->gb); code = bytestream2_get_byte(&c->gb);
if ((code & 0xF) > 4) {
avpriv_request_sample(avctx, "unknown/invalid code");
return AVERROR_INVALIDDATA;
}
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
return ret;
if (code & 0x20) { // frame is keyframe if (code & 0x20) { // frame is keyframe
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
memset(c->frame[i], 0, c->frame_size); memset(c->frame[i], 0, c->frame_size);
...@@ -367,8 +375,7 @@ static int paf_video_decode(AVCodecContext *avctx, void *data, ...@@ -367,8 +375,7 @@ static int paf_video_decode(AVCodecContext *avctx, void *data,
} }
break; break;
default: default:
avpriv_request_sample(avctx, "unknown/invalid code"); av_assert0(0);
return AVERROR_INVALIDDATA;
} }
av_image_copy_plane(c->pic->data[0], c->pic->linesize[0], av_image_copy_plane(c->pic->data[0], c->pic->linesize[0],
......
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