aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-10-26 16:29:57 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-08-23 13:15:16 +0200
commit1869ba95f6d745cc69595aab83af9be8d2f2ce9b (patch)
treecb63d5f37f4e7e326cdeda1bfd279e3951d1ff3e
parente44f0fa93945ec996eac33b5ff502a3bca100fba (diff)
downloadffmpeg-1869ba95f6d745cc69595aab83af9be8d2f2ce9b.tar.gz
avcodec/dvdsubdec: Fix buf_size check
Fixes out of array access Found-by: Thomas Garnier using libFuzzer Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 25ab1a65f3acb5ec67b53fb7a2463a7368f1ad16) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/dvdsubdec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 9272e2c012..9e793d73b2 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -506,7 +506,8 @@ static int append_to_cached_buf(AVCodecContext *avctx,
{
DVDSubContext *ctx = avctx->priv_data;
- if (ctx->buf_size >= sizeof(ctx->buf) - buf_size) {
+ av_assert0(buf_size >= 0 && ctx->buf_size <= sizeof(ctx->buf));
+ if (buf_size >= sizeof(ctx->buf) - ctx->buf_size) {
av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct "
"too large SPU packets aborted.\n");
return AVERROR_INVALIDDATA;