aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-12 16:23:27 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-12 16:23:42 +0200
commitcd326377414d02d5f6bec21609d9e6219c481ed4 (patch)
tree8b2de82d3e42c3643d8916c66e863f75a46deabc
parent189420cb561929e05f5cc4224cdca83740a24a32 (diff)
parentf1bdc234370401c032cd85184e93c7c155eb6d62 (diff)
downloadffmpeg-cd326377414d02d5f6bec21609d9e6219c481ed4.tar.gz
Merge commit 'f1bdc234370401c032cd85184e93c7c155eb6d62'
* commit 'f1bdc234370401c032cd85184e93c7c155eb6d62': riff: Validate bitrate Conflicts: libavformat/riffdec.c See: 189420cb561929e05f5cc4224cdca83740a24a32 Merged-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/riffdec.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index f798baf128..3291d6141f 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -87,6 +87,7 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
AVCodecContext *codec, int size, int big_endian)
{
int id;
+ uint64_t bitrate;
if (size < 14) {
avpriv_request_sample(codec, "wav header size < 14");
@@ -98,23 +99,15 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
id = avio_rl16(pb);
codec->channels = avio_rl16(pb);
codec->sample_rate = avio_rl32(pb);
- codec->bit_rate = avio_rl32(pb) * 8;
+ bitrate = avio_rl32(pb) * 8;
codec->block_align = avio_rl16(pb);
} else {
id = avio_rb16(pb);
codec->channels = avio_rb16(pb);
codec->sample_rate = avio_rb32(pb);
- codec->bit_rate = avio_rb32(pb) * 8;
+ bitrate = avio_rb32(pb) * 8;
codec->block_align = avio_rb16(pb);
}
- if (codec->bit_rate < 0) {
- av_log(s, AV_LOG_WARNING,
- "Invalid bit rate: %d\n", codec->bit_rate);
- if (s->error_recognition & AV_EF_EXPLODE)
- return AVERROR_INVALIDDATA;
- else
- codec->bit_rate = 0;
- }
if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */
codec->bits_per_coded_sample = 8;
} else {
@@ -155,6 +148,23 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
if (size > 0)
avio_skip(pb, size);
}
+
+ if (bitrate > INT_MAX) {
+ if (s->error_recognition & AV_EF_EXPLODE) {
+ av_log(s, AV_LOG_ERROR,
+ "The bitrate %"PRIu64" is too large.\n",
+ bitrate);
+ return AVERROR_INVALIDDATA;
+ } else {
+ av_log(s, AV_LOG_WARNING,
+ "The bitrate %"PRIu64" is too large, resetting to 0.",
+ bitrate);
+ codec->bit_rate = 0;
+ }
+ } else {
+ codec->bit_rate = bitrate;
+ }
+
if (codec->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR,
"Invalid sample rate: %d\n", codec->sample_rate);