From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28334 invoked by alias); 15 Nov 2002 09:02:32 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 28310 invoked from network); 15 Nov 2002 09:02:30 -0000 Received: from unknown (HELO dc-mx02.cluster1.charter.net) (209.225.8.12) by sources.redhat.com with SMTP; 15 Nov 2002 09:02:30 -0000 Received: from [66.189.46.2] (HELO platinum.local.) by dc-mx02.cluster1.charter.net (CommuniGate Pro SMTP 3.5.9) with ESMTP id 4895785 for gdb-patches@sources.redhat.com; Fri, 15 Nov 2002 04:02:29 -0500 Date: Fri, 15 Nov 2002 01:02:00 -0000 Mime-Version: 1.0 (Apple Message framework v543) Content-Type: multipart/mixed; boundary=Apple-Mail-4-1061689776 Subject: [RFA] Handle stack underflow in dbxread.c From: Klee Dienes To: gdb-patches@sources.redhat.com Message-Id: X-SW-Source: 2002-11/txt/msg00419.txt.bz2 --Apple-Mail-4-1061689776 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 369 2002-11-15 Klee Dienes * buildsym.h (pop_context): Check for stack underflow. * dbxread.c (process_one_symbol): Complain and stop processing that symbol if we are already at the top of the context stack for a function-end N_FUN (this would imply an umatched RBRAC). Ditto when processing N_RBRAC. --Apple-Mail-4-1061689776 Content-Disposition: attachment; filename=pop-context.txt Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="pop-context.txt" Content-length: 2654 2002-11-15 Klee Dienes * buildsym.h (pop_context): Check for stack underflow. * dbxread.c (process_one_symbol): Complain and stop processing that symbol if we are already at the top of the context stack for a function-end N_FUN (this would imply an umatched RBRAC). Ditto when processing N_RBRAC. Index: dbxread.c =================================================================== RCS file: /cvs/Darwin/src/live/cygnus/src/gdb/dbxread.c,v retrieving revision 1.38 diff -u -r1.38 dbxread.c --- dbxread.c 2002/10/26 09:20:14 1.38 +++ dbxread.c 2002/11/15 08:56:07 @@ -2946,6 +2946,11 @@ complain (&fun_end_outside_fun_complaint); break; } + if (context_stack_depth <= 0) + { + complain (&lbrac_mismatch_complaint, symnum); + break; + } saw_fun_start = 0; record_line (current_subfile, 0, last_function_start + valu); @@ -3027,6 +3032,11 @@ valu += last_source_start_addr; #endif + if (context_stack_depth <= 0) + { + complain (&lbrac_mismatch_complaint, symnum); + break; + } new = pop_context (); if (desc != new->depth) complain (&lbrac_mismatch_complaint, symnum); Index: buildsym.h =================================================================== RCS file: /cvs/Darwin/src/live/cygnus/src/gdb/buildsym.h,v retrieving revision 1.5 diff -u -r1.5 buildsym.h --- buildsym.h 2002/11/10 05:33:33 1.5 +++ buildsym.h 2002/11/15 08:56:07 @@ -22,6 +22,8 @@ #if !defined (BUILDSYM_H) #define BUILDSYM_H 1 +#include "gdb_assert.h" + /* This module provides definitions used for creating and adding to the symbol table. These routines are called from various symbol- file-reading routines. @@ -173,12 +175,6 @@ EXTERN int context_stack_size; -/* Macro "function" for popping contexts from the stack. Pushing is - done by a real function, push_context. This returns a pointer to a - struct context_stack. */ - -#define pop_context() (&context_stack[--context_stack_depth]); - /* Non-zero if the context stack is empty. */ #define outermost_context_p() (context_stack_depth == 0) @@ -271,6 +267,13 @@ extern void buildsym_init (void); extern struct context_stack *push_context (int desc, CORE_ADDR valu); + +/* Macro "function" for popping contexts from the stack. Pushing is + done by a real function, push_context. This returns a pointer to a + struct context_stack. */ + +#define pop_context() \ + (gdb_assert (context_stack_depth > 0), &context_stack[--context_stack_depth]); extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc); --Apple-Mail-4-1061689776--