gdb/gdb-6.5-dwarf-stack-overflow.patch

53 lines
1.8 KiB
Diff
Raw Normal View History

2006-09-04 07:38:09 +00:00
for gdb/ChangeLog:
2006-09-04 07:49:04 +00:00
2006-08-22 Will Drewry <wad@google.com>
Tavis Ormandy <taviso@google.com>
2006-09-04 07:38:09 +00:00
2006-09-04 07:49:04 +00:00
* dwarf2read.c (decode_locdesc): Enforce location description stack
boundaries.
2006-09-04 07:38:09 +00:00
* dwarfread.c (locval): Likewise.
2007-10-15 Jan Kratochvil <jan.kratochvil@redhat.com>
Port to GDB-6.7.
Index: gdb-7.1.90.20100711/gdb/dwarf2read.c
2006-09-04 07:38:09 +00:00
===================================================================
--- gdb-7.1.90.20100711.orig/gdb/dwarf2read.c 2010-07-12 10:43:53.000000000 +0200
+++ gdb-7.1.90.20100711/gdb/dwarf2read.c 2010-07-12 10:49:32.000000000 +0200
@@ -11382,8 +11382,7 @@ read_signatured_type (struct objfile *ob
2006-09-04 07:49:04 +00:00
callers will only want a very basic result and this can become a
complaint.
- Note that stack[0] is unused except as a default error return.
- Note that stack overflow is not yet handled. */
+ Note that stack[0] is unused except as a default error return. */
static CORE_ADDR
decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
@@ -11399,7 +11398,7 @@ decode_locdesc (struct dwarf_block *blk,
2006-09-04 07:49:04 +00:00
i = 0;
stacki = 0;
- stack[stacki] = 0;
+ stack[++stacki] = 0;
while (i < size)
{
@@ -11581,6 +11580,16 @@ decode_locdesc (struct dwarf_block *blk,
dwarf_stack_op_name (op, 1));
2006-09-04 07:38:09 +00:00
return (stack[stacki]);
}
2006-09-04 07:49:04 +00:00
+ /* Enforce maximum stack depth of size-1 to avoid ++stacki writing
+ outside of the allocated space. Also enforce minimum > 0.
+ -- wad@google.com 14 Aug 2006 */
+ if (stacki >= sizeof (stack) / sizeof (*stack) - 1)
2006-09-04 07:38:09 +00:00
+ internal_error (__FILE__, __LINE__,
2006-09-04 07:49:04 +00:00
+ _("location description stack too deep: %d"),
+ stacki);
2006-09-04 07:38:09 +00:00
+ if (stacki <= 0)
+ internal_error (__FILE__, __LINE__,
2006-09-04 07:49:04 +00:00
+ _("location description stack too shallow"));
2006-09-04 07:38:09 +00:00
}
return (stack[stacki]);
}