avformat/xmv: Make bitrate 64bit
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 13 Jul 2019 18:12:41 +0000 (20:12 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 14 Jul 2019 20:17:43 +0000 (22:17 +0200)
Fixes: signed integer overflow: 32 * 538976288 cannot be represented in type 'int'
Fixes: 15633/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5752273981931520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/xmv.c

index 29a32f2..7f12956 100644 (file)
@@ -79,7 +79,7 @@ typedef struct XMVAudioPacket {
     uint16_t channels;        ///< Number of channels.
     int32_t sample_rate;      ///< Sampling rate.
     uint16_t bits_per_sample; ///< Bits per compressed sample.
-    uint32_t bit_rate;        ///< Bits of compressed data per second.
+    uint64_t bit_rate;        ///< Bits of compressed data per second.
     uint16_t flags;           ///< Flags
     unsigned block_align;     ///< Bytes per compressed block.
     uint16_t block_samples;   ///< Decompressed samples per compressed block.
@@ -191,7 +191,7 @@ static int xmv_read_header(AVFormatContext *s)
         packet->bits_per_sample = avio_rl16(pb);
         packet->flags           = avio_rl16(pb);
 
-        packet->bit_rate      = packet->bits_per_sample *
+        packet->bit_rate      = (uint64_t)packet->bits_per_sample *
                                 packet->sample_rate *
                                 packet->channels;
         packet->block_align   = XMV_BLOCK_ALIGN_SIZE * packet->channels;