diff mbox series

[FFmpeg-devel,3/6] avcodec/movtextenc: Check for too long subtitles

Message ID AM7PR03MB66603F393B985DE760AED1DE8F679@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit f8e5e1c52333e6c330fbb4fe8ec2cb07240ca8c5
Headers show
Series [FFmpeg-devel,1/6] avcodec/movtextenc: Fix infinite loop due to variable truncation
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 30, 2021, 10:50 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/movtextenc.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 46109e0a5e..eecadaf503 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -667,6 +667,8 @@  static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
         }
     }
 
+    if (s->byte_count > UINT16_MAX)
+        return AVERROR(ERANGE);
     AV_WB16(buf, s->byte_count);
     buf += 2;