:p
atchew
Login
From: Christian Barry <christian.barry@usp.br> Replaced left-shift of a literal 1 by i inside of two for loops in compare_opcodes() with a call to BIT(i). This makes it so 1 is interpreted as an unsigned long int, preventing overflows. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2618 Signed-off-by: Christian Barry <christian.barry@usp.br> Co-developed-by: Eduardo Augusto Cavalcanti <eduardoaugustoabc@ime.usp.br> Signed-off-by: Eduardo Augusto Cavalcanti <eduardoaugustoabc@ime.usp.br> --- disas/sparc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/disas/sparc.c b/disas/sparc.c index XXXXXXX..XXXXXXX 100644 --- a/disas/sparc.c +++ b/disas/sparc.c @@ -XXX,XX +XXX,XX @@ see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "disas/dis-asm.h" /* The SPARC opcode table (and other related data) is defined in @@ -XXX,XX +XXX,XX @@ compare_opcodes (const void * a, const void * b) another, it is important to order the opcodes in the right order. */ for (i = 0; i < 32; ++i) { - unsigned long int x = 1 << i; + unsigned long int x = BIT(i); int x0 = (match0 & x) != 0; int x1 = (match1 & x) != 0; @@ -XXX,XX +XXX,XX @@ compare_opcodes (const void * a, const void * b) for (i = 0; i < 32; ++i) { - unsigned long int x = 1 << i; + unsigned long int x = BIT(i); int x0 = (lose0 & x) != 0; int x1 = (lose1 & x) != 0; -- 2.43.0
From: Christian Barry <christian.barry@usp.br> Replaced left-shift of a literal 1 by i inside of two for loops in compare_opcodes() with 1ul type qualifier. This makes it so 1 is explicitly interpreted as an unsigned long int, preventing overflows. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2618 Signed-off-by: Christian Barry <christian.barry@usp.br> Co-developed-by: Eduardo Augusto Cavalcanti <eduardoaugustoabc@ime.usp.br> Signed-off-by: Eduardo Augusto Cavalcanti <eduardoaugustoabc@ime.usp.br> --- disas/sparc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/disas/sparc.c b/disas/sparc.c index XXXXXXX..XXXXXXX 100644 --- a/disas/sparc.c +++ b/disas/sparc.c @@ -XXX,XX +XXX,XX @@ compare_opcodes (const void * a, const void * b) another, it is important to order the opcodes in the right order. */ for (i = 0; i < 32; ++i) { - unsigned long int x = 1 << i; + unsigned long int x = 1ul << i; int x0 = (match0 & x) != 0; int x1 = (match1 & x) != 0; @@ -XXX,XX +XXX,XX @@ compare_opcodes (const void * a, const void * b) for (i = 0; i < 32; ++i) { - unsigned long int x = 1 << i; + unsigned long int x = 1ul << i; int x0 = (lose0 & x) != 0; int x1 = (lose1 & x) != 0; -- 2.43.0