Commit 9ec8790a authored by Andreas Cadhalpun's avatar Andreas Cadhalpun

boadec: prevent overflow during block alignment calculation

Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
Signed-off-by: 's avatarAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
parent 169c1cfa
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavcodec/internal.h"
#include "avformat.h" #include "avformat.h"
#include "internal.h" #include "internal.h"
...@@ -53,9 +54,20 @@ static int read_header(AVFormatContext *s) ...@@ -53,9 +54,20 @@ static int read_header(AVFormatContext *s)
avio_rl32(s->pb); avio_rl32(s->pb);
st->codecpar->sample_rate = avio_rl32(s->pb); st->codecpar->sample_rate = avio_rl32(s->pb);
st->codecpar->channels = avio_rl32(s->pb); st->codecpar->channels = avio_rl32(s->pb);
if (st->codecpar->channels > FF_SANE_NB_CHANNELS) {
av_log(s, AV_LOG_ERROR, "Too many channels %d > %d\n",
st->codecpar->channels, FF_SANE_NB_CHANNELS);
return AVERROR(ENOSYS);
}
s->internal->data_offset = avio_rl32(s->pb); s->internal->data_offset = avio_rl32(s->pb);
avio_r8(s->pb); avio_r8(s->pb);
st->codecpar->block_align = st->codecpar->channels * avio_rl32(s->pb); st->codecpar->block_align = avio_rl32(s->pb);
if (st->codecpar->block_align > INT_MAX / FF_SANE_NB_CHANNELS) {
av_log(s, AV_LOG_ERROR, "Too large block alignment %d > %d\n",
st->codecpar->block_align, INT_MAX / FF_SANE_NB_CHANNELS);
return AVERROR_INVALIDDATA;
}
st->codecpar->block_align *= st->codecpar->channels;
avio_seek(s->pb, s->internal->data_offset, SEEK_SET); avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment