History

avformat/iamf_parse: sanitize audio_roll_distance values

Ensure the values are spec complaint and that no integer overflow can happen.

James Almer committed 2 years ago

Commit 9ce065c1 parent e30bc8a1 file · +14 −2Browse files

Showing the changes to libavformat (1 of 1 file). Show all

Unified · Split

libavformat/iamf_parse.c+14−2
@@ -38,7 +38,7 @@ static int opus_decoder_config(IAMFCodecConfig *codec_config, · 37 unmodified lines
3838 {
3939 int left = len - avio_tell(pb);
4040
41− if (left < 11)
41+ if (left < 11 || codec_config->audio_roll_distance >= 0)
4242 return AVERROR_INVALIDDATA;
4343
4444 codec_config->extradata = av_malloc(left + 8);
@@ -64,6 +64,9 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config, · 19 unmodified lines
6464 int object_type_id, codec_id, stream_type;
6565 int ret, tag, left;
6666
67+ if (codec_config->audio_roll_distance >= 0)
68+ return AVERROR_INVALIDDATA;
69+
6770 tag = avio_r8(pb);
6871 if (tag != MP4DecConfigDescrTag)
6972 return AVERROR_INVALIDDATA;
@@ -118,6 +121,9 @@ static int flac_decoder_config(IAMFCodecConfig *codec_config, · 48 unmodified lines
118121 {
119122 int left;
120123
124+ if (codec_config->audio_roll_distance)
125+ return AVERROR_INVALIDDATA;
126+
121127 avio_skip(pb, 4); // METADATA_BLOCK_HEADER
122128
123129 left = len - avio_tell(pb);
@@ -146,7 +152,7 @@ static int ipcm_decoder_config(IAMFCodecConfig *codec_config, · 22 unmodified lines
146152 };
147153 int sample_format = avio_r8(pb); // 0 = BE, 1 = LE
148154 int sample_size = (avio_r8(pb) / 8 - 2); // 16, 24, 32
149− if (sample_format > 1 || sample_size > 2)
155+ if (sample_format > 1 || sample_size > 2 || codec_config->audio_roll_distance)
150156 return AVERROR_INVALIDDATA;
151157
152158 codec_config->codec_id = sample_fmt[sample_format][sample_size];
@@ -246,6 +252,12 @@ static int codec_config_obu(void *s, IAMFContext *c, AVIOContext *pb, int len) · 93 unmodified lines
246252 if (ret < 0)
247253 goto fail;
248254
255+ if ((codec_config->nb_samples > INT_MAX) ||
256+ (-codec_config->audio_roll_distance > INT_MAX / codec_config->nb_samples)) {
257+ ret = AVERROR_INVALIDDATA;
258+ goto fail;
259+ }
260+
249261 c->codec_configs[c->nb_codec_configs++] = codec_config;
250262
251263 len -= avio_tell(pbc);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t