[FFmpeg-devel] [PATCH] avformat/aacdec: account for small frame sizes.

Menno de Gier mrdegier at gmail.com
Mon Apr 29 15:32:53 EEST 2019


Some ADTS files have a first frame that's shorter than the 10 bytes that
are being read while checking for ID3 tags.

Fixes #7271

Signed-off-by: Menno de Gier <mrdegier at gmail.com>
---
 libavformat/aacdec.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index bd324a1420..25bccfbcb8 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -184,6 +184,15 @@ static int adts_aac_read_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR_INVALIDDATA;
     }
 
+    if (fsize < pkt->size) {
+        ret = avio_seek(s->pb, fsize - pkt->size, SEEK_CUR);
+        if (ret < 0) {
+            av_packet_unref(pkt);
+            return ret;
+        }
+        av_shrink_packet(pkt, fsize);
+    }
+
     ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
     if (ret < 0)
         av_packet_unref(pkt);
-- 
2.19.1



More information about the ffmpeg-devel mailing list