[FFmpeg-cvslog] avcodec/exr: Check for remaining bits in huf_unpack_enc_table()

Michael Niedermayer git at videolan.org
Sun Apr 14 21:33:57 EEST 2024


ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Mon Apr  1 02:15:07 2024 +0200| [a83a4f41b38c3a0fdb5f4942376479b02b1f7d45] | committer: Michael Niedermayer

avcodec/exr: Check for remaining bits in huf_unpack_enc_table()

Fixes: Timeout
Fixes: 67645/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6308760977997824

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 589fa8a027f3b1707d78d7c45335acc498a5e887)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavcodec/exr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index c903ae12f0..eae90b602f 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -333,7 +333,10 @@ static int huf_unpack_enc_table(GetByteContext *gb,
         return ret;
 
     for (; im <= iM; im++) {
-        uint64_t l = freq[im] = get_bits(&gbit, 6);
+        uint64_t l;
+        if (get_bits_left(&gbit) < 6)
+            return AVERROR_INVALIDDATA;
+        l = freq[im] = get_bits(&gbit, 6);
 
         if (l == LONG_ZEROCODE_RUN) {
             int zerun = get_bits(&gbit, 8) + SHORTEST_LONG_RUN;



More information about the ffmpeg-cvslog mailing list