libdwfl: Make sure to left shift a unsigned 64bit value in expr_eval.
authorMark Wielaard <mark@klomp.org>
Sun, 28 Apr 2019 11:29:53 +0000 (13:29 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 28 Apr 2019 11:33:44 +0000 (13:33 +0200)
In frame_unwind.c expr_eval we left shift 1 up to 56 bits. We have to
make sure we don't left shift a 32bit signed value (that would be
undefined behavior). So shift a 1ULL value instead.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdwfl/ChangeLog
libdwfl/frame_unwind.c

index 3e19d9b..7c9a018 100644 (file)
@@ -1,5 +1,10 @@
 2019-04-28  Mark Wielaard  <mark@klomp.org>
 
+       * frame_unwind.c (expr_eval): Make sure we left shift a unsigned
+       64bit value.
+
+2019-04-28  Mark Wielaard  <mark@klomp.org>
+
        * cu.c (addrarange): Only call realloc when naranges is not zero.
 
 2019-03-27  Mark Wielaard  <mark@klomp.org>
index 8da691e..d7dfa5a 100644 (file)
@@ -336,7 +336,7 @@ expr_eval (Dwfl_Frame *state, Dwarf_Frame *frame, const Dwarf_Op *ops,
                val1 >>= (addr_bytes - op->number) * 8;
 #else
              if (op->number < 8)
-               val1 &= (1 << (op->number * 8)) - 1;
+               val1 &= (1ULL << (op->number * 8)) - 1;
 #endif
            }
          if (! push (val1))