summaryrefslogtreecommitdiff
path: root/libavcodec/libmp3lame.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2014-06-22 13:19:36 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2014-06-22 20:31:58 -0400
commitf2f2e7627f0c878d13275af5d166ec5932665e28 (patch)
tree941b6688d11ec10778656d36d44d8aee6b9a9854 /libavcodec/libmp3lame.c
parent44127546b0a81dc9dd6190739a62d48f0044c6f3 (diff)
downloadffmpeg-f2f2e7627f0c878d13275af5d166ec5932665e28.tar.gz
Check mp3 header before calling avpriv_mpegaudio_decode_header().
As indicated in the function documentation, the header MUST be checked prior to calling it because no consistency check is done there. CC:libav-stable@libav.org
Diffstat (limited to 'libavcodec/libmp3lame.c')
-rw-r--r--libavcodec/libmp3lame.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index eebc65c44d..dee1909609 100644
--- a/libavcodec/libmp3lame.c
+++ b/libavcodec/libmp3lame.c
@@ -182,6 +182,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
MPADecodeHeader hdr;
int len, ret, ch;
int lame_result;
+ uint32_t h;
if (frame) {
switch (avctx->sample_fmt) {
@@ -237,7 +238,12 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
determine the frame size. */
if (s->buffer_index < 4)
return 0;
- if (avpriv_mpegaudio_decode_header(&hdr, AV_RB32(s->buffer))) {
+ h = AV_RB32(s->buffer);
+ if (ff_mpa_check_header(h) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid mp3 header at start of buffer\n");
+ return AVERROR_BUG;
+ }
+ if (avpriv_mpegaudio_decode_header(&hdr, h)) {
av_log(avctx, AV_LOG_ERROR, "free format output not supported\n");
return -1;
}