]> sourceware.org Git - systemtap.git/commitdiff
runtime/unwind.c: Also sanity check DWARF regno for DW_CFA_restore[_extended].
authorMark Wielaard <mjw@redhat.com>
Mon, 22 Jun 2015 14:57:59 +0000 (16:57 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 22 Jun 2015 14:58:04 +0000 (16:58 +0200)
When processCFI wanted to restore a register state to its initial value it
wasn't checking whether the register was actually interesting (or existing).
DWARF_REG_MAP might return a marker (9999) that we don't know or don't care
about this register. This was checked in all the set_*_rule functions, but
not in the case we reset the rule of the register. Add this check also for
DW_CFA_restore[_extended].

runtime/unwind.c

index d38363b52c5b7e6de88b3f60e08bc9ee79e684f5..4dbab337c761144695f405b28241275f0f3d8995 100644 (file)
@@ -426,7 +426,8 @@ static int processCFI(const u8 *start, const u8 *end, unsigned long targetLoc,
                                                    value, DWARF_REG_MAP(value));
                                        value = DWARF_REG_MAP(value);
                                }
-                               memcpy(&REG_STATE.regs[value], &state->cie_regs[value], sizeof(struct unwind_item));
+                               if (value < ARRAY_SIZE(REG_STATE.regs))
+                                       memcpy(&REG_STATE.regs[value], &state->cie_regs[value], sizeof(struct unwind_item));
                                break;
                        case DW_CFA_undefined:
                                value = get_uleb128(&ptr.p8, end);
@@ -641,7 +642,8 @@ static int processCFI(const u8 *start, const u8 *end, unsigned long targetLoc,
                                            value, DWARF_REG_MAP(value));
                                value = DWARF_REG_MAP(value);
                        }
-                       memcpy(&REG_STATE.regs[value], &state->cie_regs[value], sizeof(struct unwind_item));
+                       if (value < ARRAY_SIZE(REG_STATE.regs))
+                               memcpy(&REG_STATE.regs[value], &state->cie_regs[value], sizeof(struct unwind_item));
                        break;
                }
                dbug_unwind(1, "targetLoc=%lx state->loc=%lx\n", targetLoc, state->loc);
This page took 0.023715 seconds and 5 git commands to generate.