diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-04-28 16:58:50 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-10-17 21:34:53 +0200 |
commit | b9792b3171ecc627c07f8032af7f48da6daca503 (patch) | |
tree | 3cd27f2e6e5d96994c55a31a2e3115b0bc05b915 | |
parent | 675c3942eaf64124c8cdf4a58d54b3e9f21c533f (diff) | |
download | ffmpeg-b9792b3171ecc627c07f8032af7f48da6daca503.tar.gz |
avcodec/faxcompr: Check for end of bitstream in decode_group3_1d_line() and decode_group3_2d_line()
Fixes: infinite loop
Fixes: 33674/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4816457818046464
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 08d2df41538b583932c1a6772e3c8978a2334107)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/faxcompr.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c index 400458b994..469999e046 100644 --- a/libavcodec/faxcompr.c +++ b/libavcodec/faxcompr.c @@ -206,6 +206,8 @@ static int decode_group3_1d_line(AVCodecContext *avctx, GetBitContext *gb, unsigned int run = 0; unsigned int t; for (;;) { + if (get_bits_left(gb) <= 0) + return AVERROR_INVALIDDATA; t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2); run += t; if (t < 64) { @@ -251,7 +253,10 @@ static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb, unsigned int offs = 0, run = 0; while (offs < width) { - int cmode = get_vlc2(gb, ccitt_group3_2d_vlc.table, 9, 1); + int cmode; + if (get_bits_left(gb) <= 0) + return AVERROR_INVALIDDATA; + cmode = get_vlc2(gb, ccitt_group3_2d_vlc.table, 9, 1); if (cmode == -1) { av_log(avctx, AV_LOG_ERROR, "Incorrect mode VLC\n"); return AVERROR_INVALIDDATA; |