summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2019-04-28 13:29:53 +0200
committerMark Wielaard <mark@klomp.org>2019-04-28 13:33:44 +0200
commit6f42d2dc90d2e0cfb3974f67e2ffe3d7b1723157 (patch)
tree076514588a87f96e1dfe71c635a7522d47be952d
parent6d055c058dc6880f75a1936efa5bea3c49216119 (diff)
libdwfl: Make sure to left shift a unsigned 64bit value in expr_eval.
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>
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/frame_unwind.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 3e19d9bd..7c9a018b 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -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>
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index 8da691ee..d7dfa5a9 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -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))