summaryrefslogtreecommitdiff
path: root/libavcodec/qpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-02-24 00:44:40 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2019-03-03 13:17:02 +0100
commitb819472995f55e827d6bb70dcdd86d963f65ae31 (patch)
treed199663cbe0659d813717c811a0104b7c5906de4 /libavcodec/qpeg.c
parent951bb7632fe6e3bb1a9c3b47610705871e471f34 (diff)
downloadffmpeg-b819472995f55e827d6bb70dcdd86d963f65ae31.tar.gz
avcodec/qpeg: Limit copy in qpeg_decode_intra() to the available bytes
Fixes: Timeout (27 sec -> 39 milli sec) Fixes: 13151/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QPEG_fuzzer-5717536023248896 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/qpeg.c')
-rw-r--r--libavcodec/qpeg.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index 654fd998d6..d4195c5f0b 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -99,6 +99,8 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst,
}
}
} else {
+ if (bytestream2_get_bytes_left(&qctx->buffer) < copy)
+ copy = bytestream2_get_bytes_left(&qctx->buffer);
for(i = 0; i < copy; i++) {
dst[filled++] = bytestream2_get_byte(&qctx->buffer);
if (filled >= width) {