diff options
author | Nick Clifton <nickc@redhat.com> | 2010-08-13 11:36:10 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2010-08-13 11:36:10 +0000 |
commit | 7b3fbd65ce43cb0b04b247c1f9628cec61f31d85 (patch) | |
tree | db8b1ca939acbcca43b488d1dafcf15429f6c2c6 /libiberty/argv.c | |
parent | a8dd3249418b044de6e8b1b791092aff4381b31b (diff) | |
download | gdb-7b3fbd65ce43cb0b04b247c1f9628cec61f31d85.tar.gz |
* argv.c (expandargv): Limit the number of times that response
files are opened in order to prevent infinite recursion.
Diffstat (limited to 'libiberty/argv.c')
-rw-r--r-- | libiberty/argv.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libiberty/argv.c b/libiberty/argv.c index 3084248b96c..8476c8fda9e 100644 --- a/libiberty/argv.c +++ b/libiberty/argv.c @@ -1,5 +1,5 @@ /* Create and destroy argument vectors (argv's) - Copyright (C) 1992, 2001 Free Software Foundation, Inc. + Copyright (C) 1992, 2001, 2010 Free Software Foundation, Inc. Written by Fred Fish @ Cygnus Support This file is part of the libiberty library. @@ -386,6 +386,9 @@ expandargv (int *argcp, char ***argvp) int i = 0; /* Non-zero if ***argvp has been dynamically allocated. */ int argv_dynamic = 0; + /* Limit the number of response files that we parse in order + to prevent infinite recursion. */ + unsigned int iteration_limit = 2000; /* Loop over the arguments, handling response files. We always skip ARGVP[0], as that is the name of the program being run. */ while (++i < *argcp) @@ -412,6 +415,12 @@ expandargv (int *argcp, char ***argvp) filename = (*argvp)[i]; if (filename[0] != '@') continue; + /* If we have iterated too many times then stop. */ + if (-- iteration_limit == 0) + { + fprintf (stderr, "%s: error: too many @-files encountered\n", (*argvp)[0]); + xexit (1); + } /* Read the contents of the file. */ f = fopen (++filename, "r"); if (!f) |