diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-06-10 12:27:55 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-06-10 12:27:55 +0000 |
commit | fe9204726d1b128e0447514e5ab691498874856f (patch) | |
tree | 0cb9205966f95f0e05aaa98c93a03c7255a9008f /gcc/gcc.c | |
parent | ec83cc73dcf7055ac2bfa86ed0848e48b2c8f7c5 (diff) | |
download | gcc-fe9204726d1b128e0447514e5ab691498874856f.tar.gz |
* gcc.c (process_command): Avoid assignment to read-only location.
Fix sizeof calculation.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54439 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c index cac96eb051b..c5f02d6040b 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -3192,26 +3192,27 @@ process_command (argc, argv) { const char *new_version = DEFAULT_TARGET_VERSION; const char *new_machine = DEFAULT_TARGET_MACHINE; - const char *const *new_argv = argv; + const char *progname = argv[0]; + char **new_argv; char *new_argv0; int baselen; - while (argc > 1 && new_argv[1][0] == '-' - && (new_argv[1][1] == 'V' || new_argv[1][1] == 'b')) + while (argc > 1 && argv[1][0] == '-' + && (argv[1][1] == 'V' || argv[1][1] == 'b')) { - char opt = new_argv[1][1]; + char opt = argv[1][1]; const char *arg; - if (new_argv[1][2] != '\0') + if (argv[1][2] != '\0') { - arg = new_argv[1] + 2; + arg = argv[1] + 2; argc -= 1; - new_argv += 1; + argv += 1; } else if (argc > 2) { - arg = new_argv[2]; + arg = argv[2]; argc -= 2; - new_argv += 2; + argv += 2; } else fatal ("`-%c' option must have argument", opt); @@ -3221,22 +3222,22 @@ process_command (argc, argv) new_machine = arg; } - for (baselen = strlen (argv[0]); baselen > 0; baselen--) - if (IS_DIR_SEPARATOR (argv[0][baselen-1])) + for (baselen = strlen (progname); baselen > 0; baselen--) + if (IS_DIR_SEPARATOR (progname[baselen-1])) break; - new_argv0 = xmemdup (argv[0], baselen, + new_argv0 = xmemdup (progname, baselen, baselen + concat_length (new_version, new_machine, "-gcc-", NULL) + 1); strcpy (new_argv0 + baselen, new_machine); strcat (new_argv0, "-gcc-"); strcat (new_argv0, new_version); - new_argv = xmemdup (new_argv, (argc+1) * sizeof (new_argv0[0]), - (argc+1) * sizeof (new_argv0[0])); + new_argv = xmemdup (argv, (argc + 1) * sizeof (argv[0]), + (argc + 1) * sizeof (argv[0])); new_argv[0] = new_argv0; execvp (new_argv0, new_argv); - fatal ("couldn't run `%s': %s", new_argv0, xstrerror(errno)); + fatal ("couldn't run `%s': %s", new_argv0, xstrerror (errno)); } /* Set up the default search paths. If there is no GCC_EXEC_PREFIX, |