[FFmpeg-devel] [PATCH 3/6] genh: prevent overflow during block alignment calculation

Paul B Mahol onemda at gmail.com
Thu Dec 15 11:04:12 EET 2016


On 12/15/16, Andreas Cadhalpun <andreas.cadhalpun at googlemail.com> wrote:
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> ---
>  libavformat/genh.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavformat/genh.c b/libavformat/genh.c
> index b683e02..5684352 100644
> --- a/libavformat/genh.c
> +++ b/libavformat/genh.c
> @@ -74,6 +74,11 @@ static int genh_read_header(AVFormatContext *s)
>      case  0: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;        break;
>      case  1:
>      case 11: st->codecpar->bits_per_coded_sample = 4;
> +             if (st->codecpar->channels > INT_MAX / 36) {
> +                av_log(s, AV_LOG_ERROR, "Overflow during block alignment
> calculation 36 * %d\n",
> +                       st->codecpar->channels);
> +                return AVERROR_INVALIDDATA;
> +             }
>               st->codecpar->block_align = 36 * st->codecpar->channels;
>               st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV;    break;
>      case  2: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK;        break;
> --
> 2.10.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

AFAIK codec supports only 1 or 2 channels and nothing more, but patch
if fine anyway.


More information about the ffmpeg-devel mailing list