]> git.sesse.net Git - ffmpeg/commitdiff
avformat/utils: check for overflow before reallocating side data
authorJames Almer <jamrial@gmail.com>
Sat, 19 Nov 2016 17:33:10 +0000 (14:33 -0300)
committerJames Almer <jamrial@gmail.com>
Sat, 19 Nov 2016 23:11:50 +0000 (20:11 -0300)
This makes av_stream_add_side_data() consistent with av_packet_add_side_data().

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
libavformat/utils.c

index 19bb8bd420dda24a3566867a9897a87f699d94f5..9d01babaf44dd367abcf9ad126f64d14b4937270 100644 (file)
@@ -5121,7 +5121,10 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
         }
     }
 
-    tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
+    if ((unsigned)st->nb_side_data + 1 >= INT_MAX / sizeof(*st->side_data))
+        return AVERROR(ERANGE);
+
+    tmp = av_realloc(st->side_data, st->nb_side_data + 1 * sizeof(*tmp));
     if (!tmp) {
         return AVERROR(ENOMEM);
     }