diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1994-12-06 00:51:50 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1994-12-06 00:51:50 +0000 |
| commit | 8f396ebfb6c7ea784812be8cef90eb16cdd4492d (patch) | |
| tree | 769d2ca49d84039a97bd74c4ce202b318da0828a /usr.sbin/pkg_install/lib/exec.c | |
| parent | f62ac99484084e54fb5ed6db96ca9f45ef26bf4b (diff) | |
Notes
Diffstat (limited to 'usr.sbin/pkg_install/lib/exec.c')
| -rw-r--r-- | usr.sbin/pkg_install/lib/exec.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/usr.sbin/pkg_install/lib/exec.c b/usr.sbin/pkg_install/lib/exec.c index 5232dd2b4dcf..dd6b184fffd8 100644 --- a/usr.sbin/pkg_install/lib/exec.c +++ b/usr.sbin/pkg_install/lib/exec.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: exec.c,v 1.4 1993/09/04 05:06:47 jkh Exp $"; +static const char *rcsid = "$Id: exec.c,v 1.2 1993/09/03 23:01:12 jkh Exp $"; #endif /* @@ -33,16 +33,28 @@ int vsystem(const char *fmt, ...) { va_list args; - char cmd[FILENAME_MAX * 2]; /* reasonable default for what I do */ - int ret; + char *cmd; + int ret, maxargs; + + maxargs = sysconf(_SC_ARG_MAX); + maxargs -= 32; /* some slop for the sh -c */ + cmd = malloc(maxargs); + if (!cmd) { + whinge("vsystem can't alloc arg space"); + return 1; + } va_start(args, fmt); - vsprintf(cmd, fmt, args); + if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) { + whinge("vsystem args are too long"); + return 1; + } #ifdef DEBUG printf("Executing %s\n", cmd); #endif ret = system(cmd); va_end(args); + free(cmd); return ret; } |
