diff mbox

[FFmpeg-devel] avcodec/utils: Check bits_per_coded_sample

Message ID 20190619184255.4906-1-michael@niedermayer.cc
State Accepted
Commit d33414d2ad27a5d2193c9ab0948ba7a282c2f910
Headers show

Commit Message

Michael Niedermayer June 19, 2019, 6:42 p.m. UTC
This avoids the need for each decoder separately having to handle this case

Fixes: shift exponent -100663046 is negative
Fixes: out of array access
Fixes: 15270/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5727829913763840

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

Comments

Michael Niedermayer June 26, 2019, 7:42 p.m. UTC | #1
On Wed, Jun 19, 2019 at 08:42:55PM +0200, Michael Niedermayer wrote:
> This avoids the need for each decoder separately having to handle this case
> 
> Fixes: shift exponent -100663046 is negative
> Fixes: out of array access
> Fixes: 15270/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5727829913763840
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/utils.c | 4 ++++
>  1 file changed, 4 insertions(+)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index cc04b73471..1b1feca38c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -962,6 +962,10 @@  FF_ENABLE_DEPRECATION_WARNINGS
             ret = AVERROR(EINVAL);
             goto free_and_end;
         }
+        if (avctx->bits_per_coded_sample < 0) {
+            ret = AVERROR(EINVAL);
+            goto free_and_end;
+        }
         if (avctx->sub_charenc) {
             if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) {
                 av_log(avctx, AV_LOG_ERROR, "Character encoding is only "