patches/gdb/6.7.1/225-dwarf-stack-overflow.patch
changeset 746 b150d6f590fc
parent 570 301eb285ae7d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/gdb/6.7.1/225-dwarf-stack-overflow.patch	Mon Jul 28 21:08:01 2008 +0000
     1.3 @@ -0,0 +1,52 @@
     1.4 +Original patch from gentoo: gentoo/src/patchsets/gdb/6.7.1/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.7.1.orig/gdb/dwarf2read.c gdb-6.7.1/gdb/dwarf2read.c
    1.18 +--- gdb-6.7.1.orig/gdb/dwarf2read.c	2007-09-05 02:51:48.000000000 +0200
    1.19 ++++ gdb-6.7.1/gdb/dwarf2read.c	2008-06-17 23:27:46.000000000 +0200
    1.20 +@@ -9061,8 +9061,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 +@@ -9079,7 +9078,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 +@@ -9261,6 +9260,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 + }