]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mpegts: Limit iterations of get_packet_size()
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 22 Oct 2020 18:41:48 +0000 (20:41 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 29 Nov 2020 15:10:55 +0000 (16:10 +0100)
This is a pathological case where the fuzzer provides only 2 bytes per iteration.

Fixes: Timeout (>30 -> 0.9sec)
Fixes: 26488/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTS_fuzzer-5911031077142528
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mpegts.c

index a2003c6632347b23530cd9709a4011ac21c2584b..7549fc91c933eb0045911ce6000c73ca50cc401b 100644 (file)
@@ -609,8 +609,9 @@ static int get_packet_size(AVFormatContext* s)
     /*init buffer to store stream for probing */
     uint8_t buf[PROBE_PACKET_MAX_BUF] = {0};
     int buf_size = 0;
+    int max_iterations = 16;
 
-    while (buf_size < PROBE_PACKET_MAX_BUF) {
+    while (buf_size < PROBE_PACKET_MAX_BUF && max_iterations--) {
         ret = avio_read_partial(s->pb, buf + buf_size, PROBE_PACKET_MAX_BUF - buf_size);
         if (ret < 0)
             return AVERROR_INVALIDDATA;