diff mbox

[FFmpeg-devel,1/3] avcodec/ffv1dec_template: Fix undefined shift

Message ID 20170811212123.22591-1-michael@niedermayer.cc
State Accepted
Commit 62702eebded6c6341d214405812a981f80e46ea2
Headers show

Commit Message

Michael Niedermayer Aug. 11, 2017, 9:21 p.m. UTC
Fixes: runtime error: left shift of negative value -127
Fixes: 2834/clusterfuzz-testcase-minimized-5988039123795968

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

Comments

Michael Niedermayer Aug. 12, 2017, 10:20 p.m. UTC | #1
On Fri, Aug 11, 2017 at 11:21:21PM +0200, Michael Niedermayer wrote:
> Fixes: runtime error: left shift of negative value -127
> Fixes: 2834/clusterfuzz-testcase-minimized-5988039123795968
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ffv1dec_template.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

patchset applied

[...]
diff mbox

Patch

diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c
index 61cdc90116..d41d807e64 100644
--- a/libavcodec/ffv1dec_template.c
+++ b/libavcodec/ffv1dec_template.c
@@ -149,7 +149,7 @@  static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int
             }
 
             if (lbd)
-                *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);
+                *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + ((unsigned)g<<8) + ((unsigned)r<<16) + ((unsigned)a<<24);
             else if (sizeof(TYPE) == 4) {
                 *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = g;
                 *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = b;