[FFmpeg-cvslog] avformat/mp3dec: simplify inner frame size check in mp3_read_header

Marton Balint git at videolan.org
Tue May 21 09:40:07 EEST 2024


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun May 12 19:10:18 2024 +0200| [b75e604fe5cd7da9ca713f20d1ade18d50319aff] | committer: Marton Balint

avformat/mp3dec: simplify inner frame size check in mp3_read_header

We are protecting the checked buffer with ffio_ensure_seekback(), so if the
inner check fails with a seek error, that likely means the end of file was
reached when checking for the next frame. This could also be the result of a
wrongly guessed (larger than normal) frame size, so let's continue the loop
instead of breaking out early. It will end sooner or later anyway.

Signed-off-by: Marton Balint <cus at passwd.hu>

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

 libavformat/mp3dec.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 78d6c8c71c..4abc73966f 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -412,14 +412,8 @@ static int mp3_read_header(AVFormatContext *s)
         frame_size = check(s->pb, off + i, &header);
         if (frame_size > 0) {
             ret = check(s->pb, off + i + frame_size, &header2);
-            if (ret >= 0 &&
-                (header & MP3_MASK) == (header2 & MP3_MASK))
-            {
+            if (ret >= 0 && (header & MP3_MASK) == (header2 & MP3_MASK))
                 break;
-            } else if (ret == CHECK_SEEK_FAILED) {
-                av_log(s, AV_LOG_ERROR, "Invalid frame size (%d): Could not seek to %"PRId64".\n", frame_size, off + i + frame_size);
-                return AVERROR(EINVAL);
-            }
         } else if (frame_size == CHECK_SEEK_FAILED) {
             av_log(s, AV_LOG_ERROR, "Failed to read frame size: Could not seek to %"PRId64".\n", (int64_t) (i + 1024 + frame_size + 4));
             return AVERROR(EINVAL);



More information about the ffmpeg-cvslog mailing list