aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-10-13 03:06:53 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-10-15 00:45:14 +0200
commit453da701192a7bb77fd7d85af9e7a5e04dfd19e9 (patch)
tree7d1959e5ff29f5709343bcf73b924cd912678ba0
parentd893253fcd93d11258e98857175e93be7d158708 (diff)
downloadffmpeg-453da701192a7bb77fd7d85af9e7a5e04dfd19e9.tar.gz
avcodec/pafvideo: Check for bitstream end in decode_0()
Fixes: Timeout Fixes: 3529/clusterfuzz-testcase-5057068371279872 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 9c85329cd02e9284892bf263ce6133b2fc479792) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/pafvideo.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/pafvideo.c b/libavcodec/pafvideo.c
index 9aedbc0ebe..72287e7b56 100644
--- a/libavcodec/pafvideo.c
+++ b/libavcodec/pafvideo.c
@@ -181,6 +181,8 @@ static int decode_0(PAFVideoDecContext *c, uint8_t *pkt, uint8_t code)
dend = c->frame[page] + c->frame_size;
offset = (x & 0x7F) * 2;
j = bytestream2_get_le16(&c->gb) + offset;
+ if (bytestream2_get_bytes_left(&c->gb) < (j - offset) * 16)
+ return AVERROR_INVALIDDATA;
do {
offset++;
if (dst + 3 * c->width + 4 > dend)
@@ -198,7 +200,8 @@ static int decode_0(PAFVideoDecContext *c, uint8_t *pkt, uint8_t code)
do {
set_src_position(c, &src, &send);
if ((src + 3 * c->width + 4 > send) ||
- (dst + 3 * c->width + 4 > dend))
+ (dst + 3 * c->width + 4 > dend) ||
+ bytestream2_get_bytes_left(&c->gb) < 4)
return AVERROR_INVALIDDATA;
copy_block4(dst, src, c->width, c->width, 4);
i++;