bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix undefined shift overflow


From: Michael McConville
Subject: Fix undefined shift overflow
Date: Thu, 28 Jan 2016 16:07:31 -0500

Shifting into and out of the sign bit of an integer is undefined, and
this loop unconditionally does both. The below patch should fix it. My
analysis here applies:

https://marc.info/?l=openbsd-tech&m=145377854103866&w=2

Thanks for your time,
Michael


diff --git a/opcodes/cgen-dis.c b/opcodes/cgen-dis.c
index f9f7fb2..296e99b 100644
--- a/opcodes/cgen-dis.c
+++ b/opcodes/cgen-dis.c
@@ -40,7 +40,7 @@ count_decodable_bits (const CGEN_INSN *insn)
 {
   unsigned mask = CGEN_INSN_BASE_MASK (insn);
   int bits = 0;
-  int m;
+  unsigned int m;
   for (m = 1; m != 0; m <<= 1)
     {
       if (mask & m)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]