[FFmpeg-cvslog] avcodec/adts_parser: Don't presume buffer to be padded

Andreas Rheinhardt git at videolan.org
Sat May 25 03:13:41 EEST 2024


ffmpeg | branch: release/7.0 | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu May  9 15:09:41 2024 +0200| [2bfcc11f51455a64c2248c01a5374c64606351ab] | committer: Andreas Rheinhardt

avcodec/adts_parser: Don't presume buffer to be padded

The documentation of av_adts_header_parse() does not require
the buffer to be padded at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
(cherry picked from commit 6c812a80ddfadb3e69018971a2e92ace5326db36)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2bfcc11f51455a64c2248c01a5374c64606351ab
---

 libavcodec/adts_parser.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/adts_parser.c b/libavcodec/adts_parser.c
index f2e155fc99..28ad5ef5eb 100644
--- a/libavcodec/adts_parser.c
+++ b/libavcodec/adts_parser.c
@@ -27,9 +27,14 @@
 int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t *frames)
 {
 #if CONFIG_ADTS_HEADER
+    uint8_t tmpbuf[AV_AAC_ADTS_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
     GetBitContext gb;
     AACADTSHeaderInfo hdr;
-    int err = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE);
+    int err;
+    if (!buf)
+        return AVERROR(EINVAL);
+    memcpy(tmpbuf, buf, AV_AAC_ADTS_HEADER_SIZE);
+    err = init_get_bits8(&gb, tmpbuf, AV_AAC_ADTS_HEADER_SIZE);
     if (err < 0)
         return err;
     err = ff_adts_header_parse(&gb, &hdr);



More information about the ffmpeg-cvslog mailing list