[FFmpeg-cvslog] avcodec/hevc/hevcdec: Do not allow slices to depend on failed slices
Michael Niedermayer
git at videolan.org
Thu Aug 1 03:08:30 EEST 2024
ffmpeg | branch: release/4.2 | Michael Niedermayer <michael at niedermayer.cc> | Sun Jun 23 23:17:24 2024 +0200| [aa564c7cbdd47f9a22497917db33e7e51e7fa6be] | committer: Michael Niedermayer
avcodec/hevc/hevcdec: Do not allow slices to depend on failed slices
An alternative would be to leave the context unchanged on failure of hls_slice_header()
Fixes: out of array access
Fixes: NULL pointer dereference
Fixes: 69584/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5931086299856896
Fixes: 69724/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5104066422702080
Fixes: 70422/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5908731129298944
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 5d9544cfb03d8597aa2b0037def3a4679949cec6)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa564c7cbdd47f9a22497917db33e7e51e7fa6be
---
libavcodec/hevcdec.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 799ac4af17..cbfd68a501 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -567,6 +567,10 @@ static int hls_slice_header(HEVCContext *s)
if (s->ps.pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
+ if (sh->dependent_slice_segment_flag && !s->slice_initialized) {
+ av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
+ return AVERROR_INVALIDDATA;
+ }
slice_address_length = av_ceil_log2(s->ps.sps->ctb_width *
s->ps.sps->ctb_height);
@@ -835,9 +839,6 @@ static int hls_slice_header(HEVCContext *s)
} else {
sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag;
}
- } else if (!s->slice_initialized) {
- av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
- return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = 0;
@@ -2941,8 +2942,11 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
case HEVC_NAL_RASL_N:
case HEVC_NAL_RASL_R:
ret = hls_slice_header(s);
- if (ret < 0)
+ if (ret < 0) {
+ // hls_slice_header() does not cleanup on failure thus the state now is inconsistant so we cannot use it on depandant slices
+ s->slice_initialized = 0;
return ret;
+ }
if (ret == 1) {
ret = AVERROR_INVALIDDATA;
goto fail;
More information about the ffmpeg-cvslog
mailing list