This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PACH] Fix PR bootstrap/12490
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 8 Oct 2003 14:35:13 +0200
- Subject: [PACH] Fix PR bootstrap/12490
Hi,
This patch fixes a bootstrap failure on patched versions of Solaris 9, caused
by a buffer overrun. Bootstrapped on sparc-sun-solaris2.9 (3.3 branch),
pre-approved by Mark, applied to 3.3 branch and mainline.
2003-10-08 Timo Kokkonen <tjko@iki.fi>
Eric Botcazou <ebotcazou@libertysurf.fr>
PR bootstrap/12490
* scan-decls.c (MAX_EXTERN_C_BRACES): New preprocessor constant
to define the size of the extern_C_braces array. Set it to 200.
(scan_decls): Abort when extern_C_braces_length is out-of-bounds.
--
Eric Botcazou
Index: scan-decls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/scan-decls.c,v
retrieving revision 1.30
diff -u -p -r1.30 scan-decls.c
--- scan-decls.c 9 May 2002 12:02:27 -0000 1.30
+++ scan-decls.c 8 Oct 2003 09:09:39 -0000
@@ -32,7 +32,9 @@ int brace_nesting = 0;
indicate the (brace nesting levels of) left braces that were
prefixed by extern "C". */
int extern_C_braces_length = 0;
-char extern_C_braces[20];
+/* 20 is not enough anymore on Solaris 9. */
+#define MAX_EXTERN_C_BRACES 200
+char extern_C_braces[MAX_EXTERN_C_BRACES];
#define in_extern_C_brace (extern_C_braces_length>0)
/* True if the function declaration currently being scanned is
@@ -222,6 +224,12 @@ scan_decls (pfile, argc, argv)
brace_nesting++;
extern_C_braces[extern_C_braces_length++]
= brace_nesting;
+ if (extern_C_braces_length >= MAX_EXTERN_C_BRACES)
+ {
+ fprintf (stderr,
+ "Internal error: out-of-bounds index\n");
+ exit (FATAL_EXIT_CODE);
+ }
goto new_statement;
}
}