gentoo-ebuilds/media-libs/libvorbis/files/libvorbis-1.3.7-ubsan-shift.patch
Sam James a921e04dff
media-libs/libvorbis: fix UBSAN issue and some other patches
Noticed when looking at bug #950965 but it's not related at all.

Fixes an issue with UBSAN and some other notable looking patches from
master for correctness.

Signed-off-by: Sam James <sam@gentoo.org>
2025-03-09 08:26:11 +00:00

27 lines
996 B
Diff

https://gitlab.xiph.org/xiph/vorbis/-/commit/bb4047de4c05712bf1fd49b9584c360b8e4e0adf
From bb4047de4c05712bf1fd49b9584c360b8e4e0adf Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tmatth@videolan.org>
Date: Fri, 14 Jun 2024 11:39:26 -0400
Subject: [PATCH] sharedbook: cast to unsigned to avoid undefined shift
Fixes #2351
---
lib/sharedbook.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/sharedbook.c b/lib/sharedbook.c
index 444f42b5..7a98b479 100644
--- a/lib/sharedbook.c
+++ b/lib/sharedbook.c
@@ -422,7 +422,7 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
long lo=0,hi=0;
for(i=0;i<tabn;i++){
- ogg_uint32_t word=i<<(32-c->dec_firsttablen);
+ ogg_uint32_t word=((ogg_uint32_t)i<<(32-c->dec_firsttablen));
if(c->dec_firsttable[bitreverse(word)]==0){
while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
while( hi<n && word>=(c->codelist[hi]&mask))hi++;
--
GitLab