summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-05-31 13:01:39 +0200
committerMark Wielaard <[email protected]>2018-05-31 19:48:00 +0200
commitaa02fb9028abcadaa18440b86b1ed085e029956c (patch)
tree30ca85ec66c4f0be7af59ddf9b8f81694d4b0ea5 /tests
parent7d6fe0a39f6ae5c516ffd63558e12b24297bf982 (diff)
libdw: Don't crash on invalid die in dwarf_dieoffset.
Add explicit test in get-units-invalid for dwarf_cuoffset and dwarf_dieoffset. Make sure dwarf_dieoffset returns (Dwarf_Off) -1 on failure. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog5
-rw-r--r--tests/get-units-invalid.c14
2 files changed, 18 insertions, 1 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index b656bee7..521df52f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-31 Mark Wielaard <[email protected]>
+
+ * get-units-invalid.c (main): Check dwarf_cuoffset and
+ dwarf_dieoffset.
+
2018-05-29 Mark Wielaard <[email protected]>
* dwarf-die-addr-die.c (check_dbg): Also check subdies, split or
diff --git a/tests/get-units-invalid.c b/tests/get-units-invalid.c
index 58b32c0e..ba0f818d 100644
--- a/tests/get-units-invalid.c
+++ b/tests/get-units-invalid.c
@@ -83,7 +83,19 @@ main (int argc, char *argv[])
if (dwarf_ranges (&subdie, 0, &base, &start, &end) != -1)
{
printf ("Should NOT have a ranges: %s\n",
- dwarf_diename (&result));
+ dwarf_diename (&subdie));
+ return -1;
+ }
+ if (dwarf_cuoffset (&subdie) != (Dwarf_Off) -1)
+ {
+ printf ("Should NOT have a cuoffset: %s\n",
+ dwarf_diename (&subdie));
+ return -1;
+ }
+ if (dwarf_dieoffset (&subdie) != (Dwarf_Off) -1)
+ {
+ printf ("Should NOT have a die offset: %s\n",
+ dwarf_diename (&subdie));
return -1;
}
}