mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-30 19:24:07 +00:00
* main.c (decode_env_switches): Ensure we have enough space.
Reported (with patch) by Gerte Hoogewerf <g.hoogewerf@gmail.com>
This commit is contained in:
parent
99385ee6f7
commit
889303cdfe
1 changed files with 4 additions and 5 deletions
9
main.c
9
main.c
|
@ -2925,16 +2925,14 @@ decode_env_switches (char *envar, unsigned int len)
|
||||||
/* Allocate a vector that is definitely big enough. */
|
/* Allocate a vector that is definitely big enough. */
|
||||||
argv = alloca ((1 + len + 1) * sizeof (char *));
|
argv = alloca ((1 + len + 1) * sizeof (char *));
|
||||||
|
|
||||||
/* We need a buffer to copy the value into while we split it into words
|
|
||||||
and unquote it. */
|
|
||||||
buf = alloca (2 * len);
|
|
||||||
|
|
||||||
/* getopt will look at the arguments starting at ARGV[1].
|
/* getopt will look at the arguments starting at ARGV[1].
|
||||||
Prepend a spacer word. */
|
Prepend a spacer word. */
|
||||||
argv[0] = 0;
|
argv[0] = 0;
|
||||||
argc = 1;
|
argc = 1;
|
||||||
|
|
||||||
/* Set up in case we need to prepend a dash later. */
|
/* We need a buffer to copy the value into while we split it into words
|
||||||
|
and unquote it. Set up in case we need to prepend a dash later. */
|
||||||
|
buf = alloca (1 + len + 1);
|
||||||
buf[0] = '-';
|
buf[0] = '-';
|
||||||
p = buf+1;
|
p = buf+1;
|
||||||
argv[argc] = p;
|
argv[argc] = p;
|
||||||
|
@ -2956,6 +2954,7 @@ decode_env_switches (char *envar, unsigned int len)
|
||||||
}
|
}
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
argv[++argc] = 0;
|
argv[++argc] = 0;
|
||||||
|
assert (p < buf + len + 2);
|
||||||
|
|
||||||
if (argv[1][0] != '-' && strchr (argv[1], '=') == 0)
|
if (argv[1][0] != '-' && strchr (argv[1], '=') == 0)
|
||||||
/* The first word doesn't start with a dash and isn't a variable
|
/* The first word doesn't start with a dash and isn't a variable
|
||||||
|
|
Loading…
Reference in a new issue