[FFmpeg-devel,6/8] avcodec/wmadec: Require previous exponents for reuse

Submitted by Michael Niedermayer on Oct. 31, 2019, 5:58 p.m.

Details

Message ID 20191031175830.24895-6-michael@niedermayer.cc
State Accepted
Commit c54b9fc42fee613e2c4c0dae2052ff94cd15e254
Headers show

Commit Message

Michael Niedermayer Oct. 31, 2019, 5:58 p.m.
Fixes: division by zero
Fixes: 18474/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV2_fuzzer-5764986962182144

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

Comments

Michael Niedermayer Nov. 20, 2019, 2:08 p.m.
On Thu, Oct 31, 2019 at 06:58:28PM +0100, Michael Niedermayer wrote:
> Fixes: division by zero
> Fixes: 18474/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV2_fuzzer-5764986962182144
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/wma.h    | 1 +
>  libavcodec/wmadec.c | 3 +++
>  2 files changed, 4 insertions(+)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index 325f03c44b..8344cb5b93 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -123,6 +123,7 @@  typedef struct WMACodecContext {
     uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; /* padding added */
     int last_bitoffset;
     int last_superframe_len;
+    int exponents_initialized;
     float noise_table[NOISE_TAB_SIZE];
     int noise_index;
     float noise_mult; /* XXX: suppress that and integrate it in the noise array */
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 25c1d9a452..f9260c966a 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -587,6 +587,9 @@  static int wma_decode_block(WMACodecContext *s)
                 s->exponents_bsize[ch] = bsize;
             }
         }
+        s->exponents_initialized = 1;
+    }else if (!s->exponents_initialized) {
+        return AVERROR_INVALIDDATA;
     }
 
     /* parse spectral coefficients : just RLE encoding */