Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] dwarf2read.c: Add complaint for out of bounds DW_AT_ranges attribute
@ 2003-09-10 21:20 Kevin Buettner
  2003-09-13 17:53 ` Jim Blandy
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2003-09-10 21:20 UTC (permalink / raw)
  To: gdb-patches

This one's almost obvious...

GDB for the FR-V target was segfaulting when issued the "maint
check-symtabs" command.  Clearly this is an indication that something
is wrong with the toolchain elsewhere, but GDB should not segfault
when it encounters bad debug info.

Okay?

	* dwarf2read.c (dwarf2_get_pc_bounds): Complain if offset
	associated with DW_AT_ranges attribute is out of bounds.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.101
diff -u -p -r1.101 dwarf2read.c
--- dwarf2read.c	9 Sep 2003 23:23:05 -0000	1.101
+++ dwarf2read.c	10 Sep 2003 21:11:27 -0000
@@ -2253,7 +2253,7 @@ dwarf2_get_pc_bounds (struct die_info *d
 	  unsigned int addr_size = cu_header->addr_size;
 	  CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
 	  /* Value of the DW_AT_ranges attribute is the offset in the
-	     .debug_renges section.  */
+	     .debug_ranges section.  */
 	  unsigned int offset = DW_UNSND (attr);
 	  /* Base address selection entry.  */
 	  CORE_ADDR base;
@@ -2266,6 +2266,14 @@ dwarf2_get_pc_bounds (struct die_info *d
  
 	  found_base = cu_header->base_known;
 	  base = cu_header->base_address;
+
+	  if (offset >= dwarf_ranges_size)
+	    {
+	      complaint (&symfile_complaints,
+	                 "Offset %d out of bounds for DW_AT_ranges attribute",
+			 offset);
+	      return 0;
+	    }
 	  buffer = dwarf_ranges_buffer + offset;
 
 	  /* Read in the largest possible address.  */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] dwarf2read.c: Add complaint for out of bounds DW_AT_ranges attribute
  2003-09-10 21:20 [RFA] dwarf2read.c: Add complaint for out of bounds DW_AT_ranges attribute Kevin Buettner
@ 2003-09-13 17:53 ` Jim Blandy
  2003-09-15 17:21   ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 2003-09-13 17:53 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches


Looks good.

Kevin Buettner <kevinb@redhat.com> writes:

> This one's almost obvious...
> 
> GDB for the FR-V target was segfaulting when issued the "maint
> check-symtabs" command.  Clearly this is an indication that something
> is wrong with the toolchain elsewhere, but GDB should not segfault
> when it encounters bad debug info.
> 
> Okay?
> 
> 	* dwarf2read.c (dwarf2_get_pc_bounds): Complain if offset
> 	associated with DW_AT_ranges attribute is out of bounds.
> 
> Index: dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.101
> diff -u -p -r1.101 dwarf2read.c
> --- dwarf2read.c	9 Sep 2003 23:23:05 -0000	1.101
> +++ dwarf2read.c	10 Sep 2003 21:11:27 -0000
> @@ -2253,7 +2253,7 @@ dwarf2_get_pc_bounds (struct die_info *d
>  	  unsigned int addr_size = cu_header->addr_size;
>  	  CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
>  	  /* Value of the DW_AT_ranges attribute is the offset in the
> -	     .debug_renges section.  */
> +	     .debug_ranges section.  */
>  	  unsigned int offset = DW_UNSND (attr);
>  	  /* Base address selection entry.  */
>  	  CORE_ADDR base;
> @@ -2266,6 +2266,14 @@ dwarf2_get_pc_bounds (struct die_info *d
>   
>  	  found_base = cu_header->base_known;
>  	  base = cu_header->base_address;
> +
> +	  if (offset >= dwarf_ranges_size)
> +	    {
> +	      complaint (&symfile_complaints,
> +	                 "Offset %d out of bounds for DW_AT_ranges attribute",
> +			 offset);
> +	      return 0;
> +	    }
>  	  buffer = dwarf_ranges_buffer + offset;
>  
>  	  /* Read in the largest possible address.  */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] dwarf2read.c: Add complaint for out of bounds DW_AT_ranges attribute
  2003-09-13 17:53 ` Jim Blandy
@ 2003-09-15 17:21   ` Kevin Buettner
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2003-09-15 17:21 UTC (permalink / raw)
  To: Jim Blandy, Kevin Buettner; +Cc: gdb-patches

On Sep 13, 12:51pm, Jim Blandy wrote:

> Looks good.
> 
> Kevin Buettner <kevinb@redhat.com> writes:
> 
> > This one's almost obvious...
> > 
> > GDB for the FR-V target was segfaulting when issued the "maint
> > check-symtabs" command.  Clearly this is an indication that something
> > is wrong with the toolchain elsewhere, but GDB should not segfault
> > when it encounters bad debug info.
> > 
> > Okay?
> > 
> > 	* dwarf2read.c (dwarf2_get_pc_bounds): Complain if offset
> > 	associated with DW_AT_ranges attribute is out of bounds.

Committed.

Kevin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-15 17:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-10 21:20 [RFA] dwarf2read.c: Add complaint for out of bounds DW_AT_ranges attribute Kevin Buettner
2003-09-13 17:53 ` Jim Blandy
2003-09-15 17:21   ` Kevin Buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox