mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-31 15:07:43 +00:00
ext-toolchain-wrapper.c: Handle an arbitrary amount of arguments
Even though MAXARGS 1000 seems large, it wasn't enough for at least QtWebKit package. This new version does not have any predefined limits. Closes #3907 Many thanks to Thomas for tracing the source of the build error. [Peter: Return rather than abort()] Signed-off-by: Daniel Nyström <daniel.nystrom@timeterminal.se> Reported-by: Thomas Björk <thomas.bjork@home.se> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
This commit is contained in:
parent
da7d572897
commit
e8c46b118b
@ -4,6 +4,7 @@
|
|||||||
* to ensure the external toolchain uses the correct configuration.
|
* to ensure the external toolchain uses the correct configuration.
|
||||||
*
|
*
|
||||||
* (C) 2011 Peter Korsgaard <jacmet@sunsite.dk>
|
* (C) 2011 Peter Korsgaard <jacmet@sunsite.dk>
|
||||||
|
* (C) 2011 Daniel Nyström <daniel.nystrom@timeterminal.se>
|
||||||
*
|
*
|
||||||
* This file is licensed under the terms of the GNU General Public License
|
* This file is licensed under the terms of the GNU General Public License
|
||||||
* version 2. This program is licensed "as is" without any warranty of any
|
* version 2. This program is licensed "as is" without any warranty of any
|
||||||
@ -14,12 +15,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#define MAXARGS 1000
|
|
||||||
|
|
||||||
static char path[PATH_MAX] = BR_CROSS_PATH;
|
static char path[PATH_MAX] = BR_CROSS_PATH;
|
||||||
|
|
||||||
static char *args[MAXARGS] = {
|
static char *predef_args[] = {
|
||||||
path,
|
path,
|
||||||
"--sysroot", BR_SYSROOT,
|
"--sysroot", BR_SYSROOT,
|
||||||
#ifdef BR_ARCH
|
#ifdef BR_ARCH
|
||||||
@ -54,22 +54,31 @@ static const char *get_basename(const char *name)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
char **args, **cur;
|
||||||
|
|
||||||
for (i=0; args[i]; i++);
|
cur = args = malloc(sizeof(predef_args) + (sizeof(char *) * argc));
|
||||||
|
if (args == NULL) {
|
||||||
if ((argc+i) >= MAXARGS) {
|
perror(__FILE__ ": malloc");
|
||||||
fputs("Too many arguments\n", stderr);
|
return 2;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* forward args */
|
/* start with predefined args */
|
||||||
memcpy(&args[i], &argv[1], sizeof(argv[0]) * (argc - 1));
|
memcpy(cur, predef_args, sizeof(predef_args));
|
||||||
|
cur += sizeof(predef_args) / sizeof(predef_args[0]);
|
||||||
|
|
||||||
|
/* append forward args */
|
||||||
|
memcpy(cur, &argv[1], sizeof(char *) * (argc - 1));
|
||||||
|
cur += argc - 1;
|
||||||
|
|
||||||
|
/* finish with NULL termination */
|
||||||
|
*cur = NULL;
|
||||||
|
|
||||||
strcat(path, get_basename(argv[0]));
|
strcat(path, get_basename(argv[0]));
|
||||||
|
|
||||||
if (execv(path, args))
|
if (execv(path, args))
|
||||||
perror(path);
|
perror(path);
|
||||||
|
|
||||||
|
free(args);
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user