@@ -240,7 +240,7 @@ bool parse_source_date_epoch_from_env(void)
int main(int argc, char **argv)
{
- char **args, **cur, **exec_args;
+ char **args, **cur, **exec_args, **cond_args;
char *relbasedir, *absbasedir;
char *progpath = argv[0];
char *basename;
@@ -365,7 +365,7 @@ int main(int argc, char **argv)
/* start with predefined args */
memcpy(cur, predef_args, sizeof(predef_args));
- cur += sizeof(predef_args) / sizeof(predef_args[0]);
+ cond_args = cur += sizeof(predef_args) / sizeof(predef_args[0]);
#ifdef BR_FLOAT_ABI
/* add float abi if not overridden in args */
@@ -496,6 +496,13 @@ int main(int argc, char **argv)
#endif
}
+ /* Check that we did not add more conditional args than we expected */
+ if ((cur-cond_args) > EXCLUSIVE_ARGS) {
+ errno = E2BIG;
+ perror(__FILE__ ": Not enough EXCLUSIVE_ARGS");
+ return 3;
+ }
+
/* append forward args */
memcpy(cur, &argv[1], sizeof(char *) * (argc - 1));
cur += argc - 1;