[FFmpeg-devel,4/4] avcodec/cook: Enlarge gain table

Submitted by Michael Niedermayer on Oct. 23, 2019, 6:57 p.m.

Details

Message ID 20191023185714.2412-4-michael@niedermayer.cc
State Accepted
Commit 50001cd440ac89ed125f0154dedbcfa2718d2d68
Headers show

Commit Message

Michael Niedermayer Oct. 23, 2019, 6:57 p.m.
Fixes: index 25 out of bounds for type 'float [23]'
Fixes: 18355/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_COOK_fuzzer-5641398941908992

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/cook.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer Nov. 9, 2019, 4:54 p.m.
On Wed, Oct 23, 2019 at 08:57:14PM +0200, Michael Niedermayer wrote:
> Fixes: index 25 out of bounds for type 'float [23]'
> Fixes: 18355/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_COOK_fuzzer-5641398941908992
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/cook.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 3a40ccaf2c..eb6ff9f465 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -143,7 +143,7 @@  typedef struct cook {
 
     /* generate tables and related variables */
     int                 gain_size_factor;
-    float               gain_table[23];
+    float               gain_table[31];
 
     /* data buffers */
 
@@ -185,8 +185,8 @@  static av_cold void init_gain_table(COOKContext *q)
 {
     int i;
     q->gain_size_factor = q->samples_per_channel / 8;
-    for (i = 0; i < 23; i++)
-        q->gain_table[i] = pow(pow2tab[i + 52],
+    for (i = 0; i < 31; i++)
+        q->gain_table[i] = pow(pow2tab[i + 48],
                                (1.0 / (double) q->gain_size_factor));
 }
 
@@ -670,7 +670,7 @@  static void interpolate_float(COOKContext *q, float *buffer,
         for (i = 0; i < q->gain_size_factor; i++)
             buffer[i] *= fc1;
     } else {                                        // smooth gain
-        fc2 = q->gain_table[11 + (gain_index_next - gain_index)];
+        fc2 = q->gain_table[15 + (gain_index_next - gain_index)];
         for (i = 0; i < q->gain_size_factor; i++) {
             buffer[i] *= fc1;
             fc1       *= fc2;