summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libopus
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2023-01-04 21:52:59 -0500
committerWilliam Wilgus <wilgus.william@gmail.com>2023-01-04 22:00:25 -0500
commit9367ef1ed6b78d6bc078620009e383b3deae60b2 (patch)
tree49ba08351eca22982322f2cd063a99ef34ce2e92 /lib/rbcodec/codecs/libopus
parentea33e660211ea762e0ab4b820b500db1b0c91337 (diff)
downloadrockbox-9367ef1ed6b78d6bc078620009e383b3deae60b2.tar.gz
rockbox-9367ef1ed6b78d6bc078620009e383b3deae60b2.zip
[BugFix] Fix some Shif related UB -- ASAN
these are the low hanging fruit identified by ASAN cast the byte values before shift Change-Id: Ifc5645354a10c15ccd09d1343e1705857a51e011
Diffstat (limited to 'lib/rbcodec/codecs/libopus')
-rw-r--r--lib/rbcodec/codecs/libopus/ogg/framing.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/rbcodec/codecs/libopus/ogg/framing.c b/lib/rbcodec/codecs/libopus/ogg/framing.c
index a7032a6a35..eb32351590 100644
--- a/lib/rbcodec/codecs/libopus/ogg/framing.c
+++ b/lib/rbcodec/codecs/libopus/ogg/framing.c
@@ -235,8 +235,9 @@ static int _os_lacing_expand(ogg_stream_state *os,long needed){
235 perform the checksum simultaneously with other copies */ 235 perform the checksum simultaneously with other copies */
236 236
237static ogg_uint32_t _os_update_crc(ogg_uint32_t crc, unsigned char *buffer, int size){ 237static ogg_uint32_t _os_update_crc(ogg_uint32_t crc, unsigned char *buffer, int size){
238 #define u32(v) (uint32_t)v
238 while (size>=8){ 239 while (size>=8){
239 crc^=buffer[0]<<24|buffer[1]<<16|buffer[2]<<8|buffer[3]; 240 crc^=((u32(buffer[0]))<<24)|((u32(buffer[1]))<<16)|((u32(buffer[2]))<<8)|(u32(buffer[3]));
240 241
241 crc=crc_lookup[7][ crc>>24 ]^crc_lookup[6][(crc>>16)&0xFF]^ 242 crc=crc_lookup[7][ crc>>24 ]^crc_lookup[6][(crc>>16)&0xFF]^
242 crc_lookup[5][(crc>> 8)&0xFF]^crc_lookup[4][ crc &0xFF]^ 243 crc_lookup[5][(crc>> 8)&0xFF]^crc_lookup[4][ crc &0xFF]^
@@ -246,7 +247,7 @@ static ogg_uint32_t _os_update_crc(ogg_uint32_t crc, unsigned char *buffer, int
246 buffer+=8; 247 buffer+=8;
247 size-=8; 248 size-=8;
248 } 249 }
249 250 #undef u32
250 while (size--) 251 while (size--)
251 crc=(crc<<8)^crc_lookup[0][((crc >> 24)&0xff)^*buffer++]; 252 crc=(crc<<8)^crc_lookup[0][((crc >> 24)&0xff)^*buffer++];
252 return crc; 253 return crc;