diff mbox series

[FFmpeg-devel,2/5] avcodec/mlpdec: Use 64bit for channel layout

Message ID 20220320233056.18169-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avformat/hls: Check target_duration | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Michael Niedermayer March 20, 2022, 11:30 p.m. UTC
Fixes: shift exponent 33 is too large for 32-bit type 'int'
Fixes: 45645/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-5651350182035456

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

Comments

James Almer March 20, 2022, 11:34 p.m. UTC | #1
On 3/20/2022 8:30 PM, Michael Niedermayer wrote:
> Fixes: shift exponent 33 is too large for 32-bit type 'int'
> Fixes: 45645/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-5651350182035456
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>   libavcodec/mlpdec.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
> index c51e0fbed7..2f5de9254a 100644
> --- a/libavcodec/mlpdec.c
> +++ b/libavcodec/mlpdec.c
> @@ -207,7 +207,7 @@ static enum AVChannel thd_channel_layout_extract_channel(uint64_t channel_layout
>           return AV_CHAN_NONE;
>   
>       for (i = 0; i < FF_ARRAY_ELEMS(thd_channel_order); i++)
> -        if (channel_layout & (1 << thd_channel_order[i]) && !index--)
> +        if (channel_layout & (1LL << thd_channel_order[i]) && !index--)

1ULL

>               return thd_channel_order[i];
>       return AV_CHAN_NONE;
>   }

LGTM.
Michael Niedermayer March 20, 2022, 11:53 p.m. UTC | #2
On Sun, Mar 20, 2022 at 08:34:32PM -0300, James Almer wrote:
> 
> 
> On 3/20/2022 8:30 PM, Michael Niedermayer wrote:
> > Fixes: shift exponent 33 is too large for 32-bit type 'int'
> > Fixes: 45645/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-5651350182035456
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >   libavcodec/mlpdec.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
> > index c51e0fbed7..2f5de9254a 100644
> > --- a/libavcodec/mlpdec.c
> > +++ b/libavcodec/mlpdec.c
> > @@ -207,7 +207,7 @@ static enum AVChannel thd_channel_layout_extract_channel(uint64_t channel_layout
> >           return AV_CHAN_NONE;
> >       for (i = 0; i < FF_ARRAY_ELEMS(thd_channel_order); i++)
> > -        if (channel_layout & (1 << thd_channel_order[i]) && !index--)
> > +        if (channel_layout & (1LL << thd_channel_order[i]) && !index--)
> 
> 1ULL

yes


> 
> >               return thd_channel_order[i];
> >       return AV_CHAN_NONE;
> >   }
> 
> LGTM.

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index c51e0fbed7..2f5de9254a 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -207,7 +207,7 @@  static enum AVChannel thd_channel_layout_extract_channel(uint64_t channel_layout
         return AV_CHAN_NONE;
 
     for (i = 0; i < FF_ARRAY_ELEMS(thd_channel_order); i++)
-        if (channel_layout & (1 << thd_channel_order[i]) && !index--)
+        if (channel_layout & (1LL << thd_channel_order[i]) && !index--)
             return thd_channel_order[i];
     return AV_CHAN_NONE;
 }