shithub: libopusenc

Download patch

ref: feb233a8b92a646e73e891b4c226a75ba4fd06d3
parent: 6e0a98cc0947d131640bf6816708cd940a0b8f08
author: Mark Harris <mark.hsj@gmail.com>
date: Mon Dec 28 06:47:53 EST 2020

picture.c: Fix signed shift undefined behavior

Fix ubsan report:
src/picture.c:136:17: runtime error: left shift of 255 by 24 places
cannot be represented in type 'int'

--- a/src/picture.c
+++ b/src/picture.c
@@ -119,7 +119,7 @@
 }
 
 #define READ_U32_BE(buf) \
-    (((buf)[0]<<24)|((buf)[1]<<16)|((buf)[2]<<8)|((buf)[3]&0xff))
+    (((opus_uint32)(buf)[0]<<24)|((buf)[1]<<16)|((buf)[2]<<8)|(buf)[3])
 
 /*Tries to extract the width, height, bits per pixel, and palette size of a
    PNG.