aboutsummaryrefslogtreecommitdiff
path: root/libavformat/mp3enc.c
diff options
context:
space:
mode:
authorClément Bœsch2012-11-16 10:21:17 +0200
committerClément Bœsch2012-11-16 14:11:08 +0100
commit2dd0da787ce5008d4d1b8f461fbd1288c32e2c38 (patch)
treeb37a729ceee36c0973683d4588d87b171d8f877f /libavformat/mp3enc.c
parentff3b59c848b62ca926be676fe8f31765fe34d66f (diff)
lavf/mp3enc: make sure the header is valid before writing audio pkt.
An invalid header can lead avpriv_mpegaudio_decode_header() to overread and/or div by zero.
Diffstat (limited to 'libavformat/mp3enc.c')
-rw-r--r--libavformat/mp3enc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 044eb29620..cc9f0d0919 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -262,8 +262,14 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
if (pkt->data && pkt->size >= 4) {
MPADecodeHeader c;
int av_unused base;
+ uint32_t head = AV_RB32(pkt->data);
- avpriv_mpegaudio_decode_header(&c, AV_RB32(pkt->data));
+ if (ff_mpa_check_header(head) < 0) {
+ av_log(s, AV_LOG_WARNING, "Audio packet of size %d (starting with %08X...) "
+ "is invalid, writing it anyway.\n", pkt->size, head);
+ return ff_raw_write_packet(s, pkt);
+ }
+ avpriv_mpegaudio_decode_header(&c, head);
if (!mp3->initial_bitrate)
mp3->initial_bitrate = c.bit_rate;