[FFmpeg-cvslog] avformat/mpeg: Check an avio_read() for failure

Michael Niedermayer git at videolan.org
Thu Feb 27 19:06:56 EET 2025


ffmpeg | branch: release/4.3 | Michael Niedermayer <michael at niedermayer.cc> | Sun Aug  4 21:27:44 2024 +0200| [c9a2d48c2e2c7d6959d30afecf8f90241dd48a7b] | committer: Michael Niedermayer

avformat/mpeg: Check an avio_read() for failure

Fixes: use-of-uninitialized-value
Fixes: 70849/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGPS_fuzzer-4684401009557504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 66ee75d76ce56a3553a99d67e74b8a9970c18f5b)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavcodec/mvha.c  | 4 ++--
 libavformat/mpeg.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c
index 9c7706aad7..caae39da97 100644
--- a/libavcodec/mvha.c
+++ b/libavcodec/mvha.c
@@ -187,8 +187,8 @@ static int decode_frame(AVCodecContext *avctx,
                     av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", ret);
                     return AVERROR_EXTERNAL;
                 }
-                if (zstream->avail_out > 0)
-                    memset(zstream->next_out, 0, zstream->avail_out);
+                if (s->zstream.avail_out > 0)
+                    memset(s->zstream.next_out, 0, s->zstream.avail_out);
             }
         }
     } else if (type == MKTAG('H','U','F','Y')) {
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 2a0dd5f7c9..bed3777276 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -554,7 +554,9 @@ redo:
         static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
         unsigned char buf[8];
 
-        avio_read(s->pb, buf, 8);
+        ret = avio_read(s->pb, buf, 8);
+        if (ret != 8)
+            return AVERROR_INVALIDDATA;
         avio_seek(s->pb, -8, SEEK_CUR);
         if (!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
             codec_id = AV_CODEC_ID_CAVS;



More information about the ffmpeg-cvslog mailing list