]> git.sesse.net Git - ffmpeg/commitdiff
mpegencts: Fix overflow in cbr mode period calculations
authorTimo Teräs <timo.teras@iki.fi>
Sat, 28 Nov 2015 06:27:39 +0000 (08:27 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 3 Dec 2015 16:43:30 +0000 (17:43 +0100)
ts->mux_rate is int (signed 32-bit) type. The period calculations
will start to overflow when mux_rate > 5mbps. This fixes overflows
by converting first to 64-bit type.

Fixes #5044.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mpegtsenc.c

index 468bad497ff792789e4491f4fb54db9f630bc1f0..8591e8cde6f3676f82434e221cce6ec6e17e78bd 100644 (file)
@@ -852,11 +852,11 @@ static int mpegts_write_header(AVFormatContext *s)
         ts_st = pcr_st->priv_data;
 
     if (ts->mux_rate > 1) {
-        service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) /
+        service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period /
                                      (TS_PACKET_SIZE * 8 * 1000);
-        ts->sdt_packet_period      = (ts->mux_rate * SDT_RETRANS_TIME) /
+        ts->sdt_packet_period      = (int64_t)ts->mux_rate * SDT_RETRANS_TIME /
                                      (TS_PACKET_SIZE * 8 * 1000);
-        ts->pat_packet_period      = (ts->mux_rate * PAT_RETRANS_TIME) /
+        ts->pat_packet_period      = (int64_t)ts->mux_rate * PAT_RETRANS_TIME /
                                      (TS_PACKET_SIZE * 8 * 1000);
 
         if (ts->copyts < 1)