diff mbox

[FFmpeg-devel,2/9] 4xm: prevent overflow during block alignment calculation

Message ID a446d385-4369-5687-a47c-80070904e1e5@googlemail.com
State Superseded
Headers show

Commit Message

Andreas Cadhalpun Jan. 6, 2017, 7:47 p.m. UTC
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavformat/4xm.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ronald S. Bultje Jan. 6, 2017, 7:58 p.m. UTC | #1
Hi,

On Fri, Jan 6, 2017 at 2:47 PM, Andreas Cadhalpun <
andreas.cadhalpun@googlemail.com> wrote:

> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavformat/4xm.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavformat/4xm.c b/libavformat/4xm.c
> index 2758b69d29..45949c4e97 100644
> --- a/libavformat/4xm.c
> +++ b/libavformat/4xm.c
> @@ -187,6 +187,7 @@ static int parse_strk(AVFormatContext *s,
>      st->codecpar->bit_rate              = (int64_t)st->codecpar->channels
> *
>                                            st->codecpar->sample_rate *
>                                            st->codecpar->bits_per_coded_
> sample;
> +    FF_RETURN_ON_OVERFLOW(s, st->codecpar->channels &&
> st->codecpar->bits_per_coded_sample > INT_MAX / st->codecpar->channels)
>      st->codecpar->block_align           = st->codecpar->channels *
>                                            st->codecpar->bits_per_coded_
> sample;
>
> --
> 2.11.0


To an innocent reader (who doesn't know/care about SIGFPE), this might look
like channels = 0 is an actual valid decoder condition that is explicitly
handled here.

Ronald
diff mbox

Patch

diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index 2758b69d29..45949c4e97 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -187,6 +187,7 @@  static int parse_strk(AVFormatContext *s,
     st->codecpar->bit_rate              = (int64_t)st->codecpar->channels *
                                           st->codecpar->sample_rate *
                                           st->codecpar->bits_per_coded_sample;
+    FF_RETURN_ON_OVERFLOW(s, st->codecpar->channels && st->codecpar->bits_per_coded_sample > INT_MAX / st->codecpar->channels)
     st->codecpar->block_align           = st->codecpar->channels *
                                           st->codecpar->bits_per_coded_sample;