[FFmpeg-devel,1/2] avcodec/utils: Check channels fully earlier

Submitted by Michael Niedermayer on Sept. 20, 2019, 9:09 a.m.

Details

Message ID 20190920090949.31497-1-michael@niedermayer.cc
State Accepted
Commit 83f2555e5ff571cbf5c226a920602e91228039ab
Headers show

Commit Message

Michael Niedermayer Sept. 20, 2019, 9:09 a.m.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Sept. 20, 2019, 9:16 p.m.
On Fri, Sep 20, 2019 at 11:09:48AM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/utils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply patchset so the fuzzer coverage improves


[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 729c10a8ed..c48ada599a 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -678,8 +678,8 @@  int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
     if (av_codec_is_decoder(codec))
         av_freep(&avctx->subtitle_header);
 
-    if (avctx->channels > FF_SANE_NB_CHANNELS) {
-        av_log(avctx, AV_LOG_ERROR, "Too many channels: %d\n", avctx->channels);
+    if (avctx->channels > FF_SANE_NB_CHANNELS || avctx->channels < 0) {
+        av_log(avctx, AV_LOG_ERROR, "Too many or invalid channels: %d\n", avctx->channels);
         ret = AVERROR(EINVAL);
         goto free_and_end;
     }