Make sure it's not zero, and equal or bigger than number of channels Fixes: Timeout / DOS Fixes: 67143/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-4858720481771520
Unified · Split
| @@ -543,10 +543,22 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, · 542 unmodified lines | ||
| 543 | 543 | return 0; |
| 544 | 544 | |
| 545 | 545 | if (layout_tag == MOV_CH_LAYOUT_USE_DESCRIPTIONS) { |
| 546 | − int nb_channels = ch_layout->nb_channels ? ch_layout->nb_channels : num_descr; | |
| 546 | + int nb_channels = ch_layout->nb_channels; | |
| 547 | + | |
| 548 | + if (!num_descr || num_descr < nb_channels) { | |
| 549 | + av_log(s, AV_LOG_ERROR, "got %d channel descriptions when at least %d were needed\n", | |
| 550 | + num_descr, nb_channels); | |
| 551 | + return AVERROR_INVALIDDATA; | |
| 552 | + } | |
| 553 | + | |
| 547 | 554 | if (num_descr > nb_channels) { |
| 548 | − av_log(s, AV_LOG_WARNING, "got %d channel descriptions, capping to the number of channels %d\n", | |
| 555 | + int strict = s->strict_std_compliance >= FF_COMPLIANCE_STRICT; | |
| 556 | + av_log(s, strict ? AV_LOG_ERROR : AV_LOG_WARNING, | |
| 557 | + "got %d channel descriptions when number of channels is %d\n", | |
| 549 | 558 | num_descr, nb_channels); |
| 559 | + if (strict) | |
| 560 | + return AVERROR_INVALIDDATA; | |
| 561 | + av_log(s, AV_LOG_WARNING, "capping channel descriptions to the number of channels\n"); | |
| 550 | 562 | num_descr = nb_channels; |
| 551 | 563 | } |
| 552 | 564 | |