From 066d126b7b14c65bdea2ad36568de66883f3ae3c Mon Sep 17 00:00:00 2001 From: rhb Date: Tue, 25 Jul 2023 14:31:10 +0200 Subject: [PATCH 1/2] fix issue 625: UBSAN index out-of-bounds --- lib_com/options.h | 1 + lib_dec/ivas_spar_decoder.c | 4 ++++ 2 files changed, 5 insertions(+) mode change 100644 => 100755 lib_dec/ivas_spar_decoder.c diff --git a/lib_com/options.h b/lib_com/options.h index c2bc0b866b..1cd3e0754c 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -209,6 +209,7 @@ #define FIX_615_UBSAN_SPAR_TO_DIRAC /*Dlb : Fix for UBSAN issue 615*/ #define FIX_626_VARIABLE_TYPE_MDCT_CONC /* FhG: trivial fix to fix USAN error */ #define FIX_616_DIV_ZERO_MCT /*FhG : Fix UBSAN division by zero error of issue 616*/ +#define FIX_625_IDX_OOB /* FhG: Fix index out-of-bounds UBSAN error (issue 625) */ /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c old mode 100644 new mode 100755 index 1c839316e5..281c5e9f11 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1026,7 +1026,11 @@ static void ivas_spar_calc_smooth_facs( /* calculate band-wise subframe energies */ subframe_band_nrg[b] = 0.f; +#ifdef FIX_625_IDX_OOB + while ( bin < CLDFB_NO_CHANNELS_MAX && b == bin2band->p_cldfb_map_to_spar_band[bin] ) +#else while ( b == bin2band->p_cldfb_map_to_spar_band[bin] ) +#endif { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { -- GitLab From 4c8efefb7b3bb6e6ad96bf44c30c72f0a62ac42a Mon Sep 17 00:00:00 2001 From: rhb Date: Wed, 26 Jul 2023 17:28:57 +0200 Subject: [PATCH 2/2] add another safety check --- lib_dec/ivas_spar_decoder.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 281c5e9f11..195bf57dfb 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1019,7 +1019,11 @@ static void ivas_spar_calc_smooth_facs( bin = 0; for ( b = 0; b < nbands_spar; b++ ) { +#ifdef FIX_625_IDX_OOB + if ( bin >= CLDFB_NO_CHANNELS_MAX || ( b > 0 && bin2band->p_cldfb_map_to_spar_band[bin] < bin2band->p_cldfb_map_to_spar_band[bin - 1] ) ) +#else if ( b > 0 && bin2band->p_cldfb_map_to_spar_band[bin] < bin2band->p_cldfb_map_to_spar_band[bin - 1] ) +#endif { break; } -- GitLab