summaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorbrolley <brolley@138bc75d-0d04-0410-961f-82ee72b054a4>1999-04-13 09:43:28 +0000
committerbrolley <brolley@138bc75d-0d04-0410-961f-82ee72b054a4>1999-04-13 09:43:28 +0000
commitd850ae28ce72359286369250a42471a9342c1835 (patch)
treef4087acd43a3c4a6118901005fd181d1ca707299 /gcc/cppinit.c
parent8304109572fee7e5d31a4b63288c51d77e7be0c0 (diff)
downloadgcc-d850ae28ce72359286369250a42471a9342c1835.tar.gz
Tue Apr 13 12:14:07 1999 Dave Brolley <brolley@cygnus.com>
* cppinit.c (cpp_start_read): Fix buffer overwrite. * Makefile.in (cppinit.o): Typo in dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26401 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 73008008357..d02a1f9b827 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -881,22 +881,21 @@ cpp_start_read (pfile, fname)
{
struct default_include *p = include_defaults_array;
char *specd_prefix = opts->include_prefix;
- char *default_prefix = alloca (sizeof GCC_INCLUDE_DIR - 7);
- int default_len;
- int specd_len;
/* Search "translated" versions of GNU directories.
These have /usr/local/lib/gcc... replaced by specd_prefix. */
if (specd_prefix != 0)
{
+ char *default_prefix = alloca (sizeof GCC_INCLUDE_DIR - 7);
/* Remove the `include' from /usr/local/lib/gcc.../include.
GCC_INCLUDE_DIR will always end in /include. */
+ int default_len = sizeof GCC_INCLUDE_DIR - 8;
+ int specd_len = strlen (specd_prefix);
+
default_len = sizeof GCC_INCLUDE_DIR - 8;
memcpy (default_prefix, GCC_INCLUDE_DIR, default_len);
default_prefix[default_len] = '\0';
-
- specd_len = strlen (specd_prefix);
for (p = include_defaults_array; p->fname; p++)
{
/* Some standard dirs are only for C++. */
@@ -909,10 +908,12 @@ cpp_start_read (pfile, fname)
{
/* Yes; change prefix and add to search list. */
int flen = strlen (p->fname);
- int this_len = specd_len - default_len + flen;
+ int this_len = specd_len + flen - default_len;
char *str = (char *) xmalloc (this_len + 1);
memcpy (str, specd_prefix, specd_len);
- memcpy (str+specd_len, p->fname, flen + 1);
+ memcpy (str + specd_len,
+ p->fname + default_len,
+ flen - default_len + 1);
append_include_chain (pfile, opts->pending,
str, SYSTEM);