+2010-11-19 Will Drewry <wad@google.com>
+ Tavis Ormandy <taviso@google.com>
+ Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * dwarf2read.c (decode_locdesc): Enforce location description stack
+ boundaries.
+
2010-11-18 Pierre Muller <muller@ics.u-strasbg.fr>
* arm-tdep.c (arm_in_function_epilogue_p): Fix code when "MOV SP"
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)
i = 0;
stacki = 0;
stack[stacki] = 0;
+ stack[++stacki] = 0;
while (i < size)
{
dwarf_stack_op_name (op, 1));
return (stack[stacki]);
}
+
+ /* Enforce maximum stack depth of SIZE-1 to avoid writing
+ outside of the allocated space. Also enforce minimum>0. */
+ if (stacki >= ARRAY_SIZE (stack) - 1)
+ {
+ complaint (&symfile_complaints,
+ _("location description stack overflow"));
+ return 0;
+ }
+
+ if (stacki <= 0)
+ {
+ complaint (&symfile_complaints,
+ _("location description stack underflow"));
+ return 0;
+ }
}
return (stack[stacki]);
}