summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-06-08 20:45:48 +0200
committerMark Wielaard <mark@klomp.org>2018-06-11 08:35:51 +0200
commit95e3d07a6742992cf22e239389cab12ba0d4d95d (patch)
tree36da03c165aaad8e191b4e41b85cfa3d672a1556 /tests
parentb958e6b0fbe6aa246bbbbdec34487476b01d1f2e (diff)
downloadelfutils-95e3d07a6742992cf22e239389cab12ba0d4d95d.tar.gz
libdw: Check validity of dwarf_getabbrev arguments.
When the given Dwarf_Die was invalid we might crash and when the offset was totally bogus we might succeed with a random abbrev. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog5
-rw-r--r--tests/get-units-invalid.c6
-rw-r--r--tests/show-abbrev.c8
3 files changed, 19 insertions, 0 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 25ed41e7..3b69a87c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,10 @@
2018-06-08 Mark Wielaard <mark@klomp.org>
+ * get-units-invalid.c (main): Check invalid dwarf_getabbrev call.
+ * show-abbrev.c (main): Check illegal dwarf_getabbrev offset call.
+
+2018-06-08 Mark Wielaard <mark@klomp.org>
+
* varlocs.c (main): Only assert when cfi_debug_bias != 0 if there
actually is a cfi_debug.
diff --git a/tests/get-units-invalid.c b/tests/get-units-invalid.c
index ba0f818d..155e12db 100644
--- a/tests/get-units-invalid.c
+++ b/tests/get-units-invalid.c
@@ -98,6 +98,12 @@ main (int argc, char *argv[])
dwarf_diename (&subdie));
return -1;
}
+ if (dwarf_getabbrev (&subdie, 0, NULL) != NULL)
+ {
+ printf ("Should NOT have an abbrev: %s\n",
+ dwarf_diename (&subdie));
+ return -1;
+ }
}
else if (unit_type == DW_UT_type)
printf ("subdie: %s\n", dwarf_diename (&subdie));
diff --git a/tests/show-abbrev.c b/tests/show-abbrev.c
index b0af0297..002ae25e 100644
--- a/tests/show-abbrev.c
+++ b/tests/show-abbrev.c
@@ -51,6 +51,14 @@ main (int argc, char *argv[])
/* Something went wrong. */
break;
+ /* Test something obviously wrong. */
+ Dwarf_Abbrev *a = dwarf_getabbrev (&die, (Dwarf_Off) -1, NULL);
+ if (a != NULL)
+ {
+ printf ("dwarf_getabbrev -1 succeeded?\n");
+ break;
+ }
+
Dwarf_Off offset = 0;
while (1)