]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/au.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavformat / au.c
index b29b45d3c71307ade043a905b7412535defa10fc..b78d1ac18ef8a8421841518dd0576df4ec54b63f 100644 (file)
@@ -150,6 +150,11 @@ static int au_read_header(AVFormatContext *s)
         return AVERROR_INVALIDDATA;
     }
 
+    if (channels == 0 || channels > 64) {
+        av_log(s, AV_LOG_ERROR, "Invalid number of channels %d\n", channels);
+        return AVERROR_INVALIDDATA;
+    }
+
     if (size >= 24) {
         /* skip unused data */
         avio_skip(pb, size - 24);
@@ -165,7 +170,7 @@ static int au_read_header(AVFormatContext *s)
     st->codec->channels = channels;
     st->codec->sample_rate = rate;
     if (data_size != AU_UNKNOWN_SIZE)
-    st->duration = (((int64_t)data_size)<<3) / (st->codec->channels * bps);
+    st->duration = (((int64_t)data_size)<<3) / (st->codec->channels * (int64_t)bps);
     avpriv_set_pts_info(st, 64, 1, rate);
     return 0;
 }
@@ -182,11 +187,8 @@ static int au_read_packet(AVFormatContext *s,
                        av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);
     if (ret < 0)
         return ret;
+    pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
     pkt->stream_index = 0;
-
-    /* note: we need to modify the packet size here to handle the last
-       packet */
-    pkt->size = ret;
     return 0;
 }
 
@@ -198,7 +200,7 @@ AVInputFormat ff_au_demuxer = {
     .read_header    = au_read_header,
     .read_packet    = au_read_packet,
     .read_seek      = ff_pcm_read_seek,
-    .codec_tag= (const AVCodecTag* const []){codec_au_tags, 0},
+    .codec_tag      = (const AVCodecTag* const []){ codec_au_tags, 0 },
 };
 #endif
 
@@ -213,6 +215,6 @@ AVOutputFormat ff_au_muxer = {
     .write_header      = au_write_header,
     .write_packet      = au_write_packet,
     .write_trailer     = au_write_trailer,
-    .codec_tag= (const AVCodecTag* const []){codec_au_tags, 0},
+    .codec_tag         = (const AVCodecTag* const []){ codec_au_tags, 0 },
 };
 #endif //CONFIG_AU_MUXER