[FFmpeg-cvslog] avcodec/wmadec: Keep track of exponent initialization per channel

2020-04-23 Thread Michael Niedermayer
ffmpeg | branch: release/2.8 | Michael Niedermayer  | 
Sat Nov 30 16:46:46 2019 +0100| [a35b01b84ae32d401bd6ec81a7cff5d369a8394a] | 
committer: Michael Niedermayer

avcodec/wmadec: Keep track of exponent initialization per channel

Fixes: division by 0
Fixes: 
19123/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV2_fuzzer-5655493121146880

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit bf5c850b795126d4f60dd9498c06f0492f5726a7)
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a35b01b84ae32d401bd6ec81a7cff5d369a8394a
---

 libavcodec/wma.h| 2 +-
 libavcodec/wmadec.c | 9 ++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index ec618d1e64..3126df7ebe 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -123,7 +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;
+int exponents_initialized[MAX_CHANNELS];
 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 adf8e491c1..745e29b34b 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -584,11 +584,14 @@ static int wma_decode_block(WMACodecContext *s)
 decode_exp_lsp(s, ch);
 }
 s->exponents_bsize[ch] = bsize;
+s->exponents_initialized[ch] = 1;
 }
 }
-s->exponents_initialized = 1;
-}else if (!s->exponents_initialized) {
-return AVERROR_INVALIDDATA;
+}
+
+for (ch = 0; ch < s->avctx->channels; ch++) {
+if (s->channel_coded[ch] && !s->exponents_initialized[ch])
+return AVERROR_INVALIDDATA;
 }
 
 /* parse spectral coefficients : just RLE encoding */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avcodec/wmadec: Keep track of exponent initialization per channel

2019-12-28 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sat 
Nov 30 16:46:46 2019 +0100| [bf5c850b795126d4f60dd9498c06f0492f5726a7] | 
committer: Michael Niedermayer

avcodec/wmadec: Keep track of exponent initialization per channel

Fixes: division by 0
Fixes: 
19123/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV2_fuzzer-5655493121146880

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bf5c850b795126d4f60dd9498c06f0492f5726a7
---

 libavcodec/wma.h| 2 +-
 libavcodec/wmadec.c | 9 ++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index 8344cb5b93..c7fcf5047c 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -123,7 +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;
+int exponents_initialized[MAX_CHANNELS];
 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 bb9bc8d236..6365fe7f47 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -585,11 +585,14 @@ static int wma_decode_block(WMACodecContext *s)
 decode_exp_lsp(s, ch);
 }
 s->exponents_bsize[ch] = bsize;
+s->exponents_initialized[ch] = 1;
 }
 }
-s->exponents_initialized = 1;
-}else if (!s->exponents_initialized) {
-return AVERROR_INVALIDDATA;
+}
+
+for (ch = 0; ch < s->avctx->channels; ch++) {
+if (s->channel_coded[ch] && !s->exponents_initialized[ch])
+return AVERROR_INVALIDDATA;
 }
 
 /* parse spectral coefficients : just RLE encoding */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".