]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/movtextenc: Check for too many styles
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 20 Feb 2021 22:42:04 +0000 (23:42 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 24 Feb 2021 06:50:39 +0000 (07:50 +0100)
The counter for the number of styles is written on two bytes, ergo
anything > UINT16_MAX is invalid. This also fixes a compiler warning
because of a tautologically true check on 64bit systems.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/movtextenc.c

index 1bef21e0b9b04341a3c6443c1df6cff81ccab207..cf30adbd0adbf61f2bc3b3d390a13a647cd9b4d8 100644 (file)
@@ -355,7 +355,7 @@ static int mov_text_style_start(MovTextContext *s)
         StyleBox *tmp;
 
         // last style != defaults, end the style entry and start a new one
-        if (s->count + 1 > SIZE_MAX / sizeof(*s->style_attributes) ||
+        if (s->count + 1 > FFMIN(SIZE_MAX / sizeof(*s->style_attributes), UINT16_MAX) ||
             !(tmp = av_fast_realloc(s->style_attributes,
                                     &s->style_attributes_bytes_allocated,
                                     (s->count + 1) * sizeof(*s->style_attributes)))) {