shithub: opus-tools

Download patch

ref: bc3dcac66196d162c4e88e3113c6813efe61e7fa
parent: 4b3c9c792fabbc3a585dddf1cbebd582cf81b53d
author: Mark Harris <[email protected]>
date: Sat Sep 4 08:07:51 EDT 2021

opusinfo: Fix signed shift undefined behavior

--- a/src/opusinfo.c
+++ b/src/opusinfo.c
@@ -101,7 +101,7 @@
 }
 
 #define READ_U32_BE(buf) \
-    (((buf)[0]<<24)|((buf)[1]<<16)|((buf)[2]<<8)|((buf)[3]&0xff))
+    (((ogg_uint32_t)(buf)[0]<<24)|((buf)[1]<<16)|((buf)[2]<<8)|(buf)[3])
 
 void check_xiph_comment(stream_processor *stream, int i, const char *comment,
     int comment_length)
--- a/src/picture.c
+++ b/src/picture.c
@@ -51,7 +51,7 @@
 }
 
 #define READ_U32_BE(buf) \
-    (((buf)[0]<<24)|((buf)[1]<<16)|((buf)[2]<<8)|((buf)[3]&0xff))
+    (((ogg_uint32_t)(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.