diff mbox

[FFmpeg-devel,1/3] avcodec/exr: fix undefined shift in pxr24_uncompress()

Message ID 20171104001921.24006-1-michael@niedermayer.cc
State Accepted
Commit 66f0c958bfd5475658b432d1af4d2e174b2dfcda
Headers show

Commit Message

Michael Niedermayer Nov. 4, 2017, 12:19 a.m. UTC
Fixes: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
Fixes: 3787/clusterfuzz-testcase-minimized-5728764920070144

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

Comments

Paul B Mahol Nov. 4, 2017, 9:21 a.m. UTC | #1
On 11/4/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: runtime error: left shift of 255 by 24 places cannot be represented
> in type 'int'
> Fixes: 3787/clusterfuzz-testcase-minimized-5728764920070144
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/exr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/exr.c b/libavcodec/exr.c
> index 0b755db3cb..b1ecde4ebd 100644
> --- a/libavcodec/exr.c
> +++ b/libavcodec/exr.c
> @@ -855,7 +855,7 @@ static int pxr24_uncompress(EXRContext *s, const uint8_t
> *src,
>                  in     = ptr[2] + td->xsize;
>
>                  for (j = 0; j < td->xsize; ++j) {
> -                    uint32_t diff = (*(ptr[0]++) << 24) |
> +                    uint32_t diff = ((unsigned)*(ptr[0]++) << 24) |
>                                      (*(ptr[1]++) << 16) |
>                                      (*(ptr[2]++) << 8);
>                      pixel += diff;
> --
> 2.15.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

ok
Michael Niedermayer Nov. 4, 2017, 8:07 p.m. UTC | #2
On Sat, Nov 04, 2017 at 10:21:37AM +0100, Paul B Mahol wrote:
> On 11/4/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: runtime error: left shift of 255 by 24 places cannot be represented
> > in type 'int'
> > Fixes: 3787/clusterfuzz-testcase-minimized-5728764920070144
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/exr.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/exr.c b/libavcodec/exr.c
> > index 0b755db3cb..b1ecde4ebd 100644
> > --- a/libavcodec/exr.c
> > +++ b/libavcodec/exr.c
> > @@ -855,7 +855,7 @@ static int pxr24_uncompress(EXRContext *s, const uint8_t
> > *src,
> >                  in     = ptr[2] + td->xsize;
> >
> >                  for (j = 0; j < td->xsize; ++j) {
> > -                    uint32_t diff = (*(ptr[0]++) << 24) |
> > +                    uint32_t diff = ((unsigned)*(ptr[0]++) << 24) |
> >                                      (*(ptr[1]++) << 16) |
> >                                      (*(ptr[2]++) << 8);
> >                      pixel += diff;
> > --
> > 2.15.0
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> 
> ok

will apply

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 0b755db3cb..b1ecde4ebd 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -855,7 +855,7 @@  static int pxr24_uncompress(EXRContext *s, const uint8_t *src,
                 in     = ptr[2] + td->xsize;
 
                 for (j = 0; j < td->xsize; ++j) {
-                    uint32_t diff = (*(ptr[0]++) << 24) |
+                    uint32_t diff = ((unsigned)*(ptr[0]++) << 24) |
                                     (*(ptr[1]++) << 16) |
                                     (*(ptr[2]++) << 8);
                     pixel += diff;