[FFmpeg-cvslog] avcodec/huffyuvdec: avoid undefined behavior with get_vlc2() failure

Michael Niedermayer git at videolan.org
Sun Apr 14 23:23:40 EEST 2024


ffmpeg | branch: release/4.2 | Michael Niedermayer <michael at niedermayer.cc> | Tue Jun 20 00:13:43 2023 +0200| [d3071db595dce49348322922753d8d1bb7d8cf0b] | committer: Michael Niedermayer

avcodec/huffyuvdec: avoid undefined behavior with get_vlc2() failure

Fixes: left shift of negative value -1
Fixes: 59889/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HUFFYUV_fuzzer-5472742275940352

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

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

 libavcodec/huffyuvdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 2562ef97d8..4c4bec9829 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -751,7 +751,7 @@ static void decode_plane_bitstream(HYuvContext *s, int width, int plane)
             }
         }
         if( width&1 && get_bits_left(&s->gb)>0 ) {
-            int dst = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;
+            int dst = (unsigned)get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;
             s->temp16[0][width-1] = dst + get_bits(&s->gb, 2);
         }
     }



More information about the ffmpeg-cvslog mailing list