summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2015-10-09 15:16:46 +0200
committerAnton Khirnov <anton@khirnov.net>2015-12-12 21:25:42 +0100
commit955aec3c7c7be39b659197e1ec379a09f2b7c41c (patch)
tree492417dfa6f76fc48144e966f762c4176e6a4706 /libavformat
parentcea1eef25c3310a68dd327eb74aae14ad3c2ddef (diff)
mpegaudiodecheader: check the header in avpriv_mpegaudio_decode_header
Almost all the places from which this function is called already check the header manually and in the two that don't (the mp3 muxer) the check should not cause any problems.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mp3dec.c12
-rw-r--r--libavformat/mp3enc.c5
2 files changed, 10 insertions, 7 deletions
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index a875b82c0a..8904797491 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -275,14 +275,16 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
MPADecodeHeader c;
int vbrtag_size = 0;
MP3DecContext *mp3 = s->priv_data;
+ int ret;
ffio_init_checksum(s->pb, ff_crcA001_update, 0);
v = avio_rb32(s->pb);
- if(ff_mpa_check_header(v) < 0)
- return -1;
- if (avpriv_mpegaudio_decode_header(&c, v) == 0)
+ ret = avpriv_mpegaudio_decode_header(&c, v);
+ if (ret < 0)
+ return ret;
+ else if (ret == 0)
vbrtag_size = c.frame_size;
if(c.layer != 3)
return -1;
@@ -388,8 +390,8 @@ static int check(AVIOContext *pb, int64_t pos, int64_t *out_pos)
header = avio_rb32(pb);
- if (ff_mpa_check_header(header) < 0 ||
- avpriv_mpegaudio_decode_header(&mh, header))
+
+ if (avpriv_mpegaudio_decode_header(&mh, header))
break;
out_pos[i] = off;
}
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index e4c6dbb223..42b3296512 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -306,11 +306,12 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
if (mp3->xing_offset && pkt->size >= 4) {
MPADecodeHeader c;
+ int ret;
uint32_t h;
h = AV_RB32(pkt->data);
- if (ff_mpa_check_header(h) == 0) {
- avpriv_mpegaudio_decode_header(&c, h);
+ ret = avpriv_mpegaudio_decode_header(&c, h);
+ if (ret >= 0) {
if (!mp3->initial_bitrate)
mp3->initial_bitrate = c.bit_rate;
if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))