Don't support --args inside an --args file

This would let you create a recursive operation filling up the stack
and causing a crash.

Closes: #47
Approved by: cgwalters
This commit is contained in:
Alexander Larsson
2016-05-06 10:22:36 +02:00
committed by Colin Walters (automation)
parent 055f58c245
commit 90c20f2c8e

View File

@@ -799,7 +799,8 @@ int opt_seccomp_fd = -1;
static void
parse_args (int *argcp,
char ***argvp)
char ***argvp,
bool in_file)
{
SetupOp *op;
int argc = *argcp;
@@ -828,6 +829,9 @@ parse_args (int *argcp,
int data_argc;
int i;
if (in_file)
die ("--args not supported in arguments file");
if (argc < 2)
die ("--args takes an argument");
@@ -866,7 +870,7 @@ parse_args (int *argcp,
}
data_argv_copy = data_argv; /* Don't change data_argv, we need to free it */
parse_args (&data_argc, &data_argv_copy);
parse_args (&data_argc, &data_argv_copy, TRUE);
argv += 1;
argc -= 1;
@@ -1200,7 +1204,7 @@ main (int argc,
if (argc == 0)
usage (EXIT_FAILURE);
parse_args (&argc, &argv);
parse_args (&argc, &argv, FALSE);
/* We have to do this if we weren't installed setuid, so let's just DWIM */
if (!is_privileged)