patches/gdb/6.8a/100-dwarf-stack-overflow.patch
branch1.12
changeset 2681 d891b4cfd080
parent 746 b150d6f590fc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/gdb/6.8a/100-dwarf-stack-overflow.patch	Sun Sep 11 18:28:45 2011 +0200
     1.3 @@ -0,0 +1,52 @@
     1.4 +Original patch from gentoo: gentoo/src/patchsets/gdb/6.8/80_all_gdb-6.5-dwarf-stack-overflow.patch
     1.5 +-= BEGIN original header =-
     1.6 +http://bugs.gentoo.org/144833
     1.7 +
     1.8 +for gdb/ChangeLog:
     1.9 +2006-08-22  Will Drewry <wad@google.com>
    1.10 +	    Tavis Ormandy <taviso@google.com>
    1.11 +
    1.12 +	* dwarf2read.c (decode_locdesc): Enforce location description stack
    1.13 +	boundaries.
    1.14 +	* dwarfread.c (locval): Likewise.
    1.15 +
    1.16 +-= END original header =-
    1.17 +diff -durN gdb-6.8.orig/gdb/dwarf2read.c gdb-6.8/gdb/dwarf2read.c
    1.18 +--- gdb-6.8.orig/gdb/dwarf2read.c	2008-03-10 15:18:10.000000000 +0100
    1.19 ++++ gdb-6.8/gdb/dwarf2read.c	2008-06-17 16:07:31.000000000 +0200
    1.20 +@@ -9124,8 +9124,7 @@
    1.21 +    callers will only want a very basic result and this can become a
    1.22 +    complaint.
    1.23 + 
    1.24 +-   Note that stack[0] is unused except as a default error return.
    1.25 +-   Note that stack overflow is not yet handled.  */
    1.26 ++   Note that stack[0] is unused except as a default error return. */
    1.27 + 
    1.28 + static CORE_ADDR
    1.29 + decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
    1.30 +@@ -9142,7 +9141,7 @@
    1.31 + 
    1.32 +   i = 0;
    1.33 +   stacki = 0;
    1.34 +-  stack[stacki] = 0;
    1.35 ++  stack[++stacki] = 0;
    1.36 + 
    1.37 +   while (i < size)
    1.38 +     {
    1.39 +@@ -9324,6 +9323,16 @@
    1.40 + 		     dwarf_stack_op_name (op));
    1.41 + 	  return (stack[stacki]);
    1.42 + 	}
    1.43 ++      /* Enforce maximum stack depth of size-1 to avoid ++stacki writing
    1.44 ++         outside of the allocated space. Also enforce minimum > 0.
    1.45 ++         -- wad@google.com 14 Aug 2006 */
    1.46 ++      if (stacki >= sizeof (stack) / sizeof (*stack) - 1)
    1.47 ++	internal_error (__FILE__, __LINE__,
    1.48 ++	                _("location description stack too deep: %d"),
    1.49 ++	                stacki);
    1.50 ++      if (stacki <= 0)
    1.51 ++	internal_error (__FILE__, __LINE__,
    1.52 ++	                _("location description stack too shallow"));
    1.53 +     }
    1.54 +   return (stack[stacki]);
    1.55 + }