From 928e318914ce5e5f8678fa87c4d4404d28a95a89 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 21 Jun 1999 22:33:52 +0000 Subject: fix bug in parsing command arguments --- src/process.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/process.c b/src/process.c index 0681b8f4..ccde94cc 100644 --- a/src/process.c +++ b/src/process.c @@ -105,6 +105,9 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, int x,y,rc=-1; int done=0; int output=0; + char **cmdargs=NULL; + char **tmpargs=NULL; + int cmdargc; pipe(outpipe); @@ -153,15 +156,15 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, logString(cmdname,tmpstr); } } else { - char **cmdargs=NULL; - char **tmpargs=NULL; - int cmdargc,x; + cmdargs=NULL; + tmpargs=NULL; + cmdargc=0; poptParseArgvString(tmpstr,&cmdargc,&tmpargs); - cmdargs=malloc( (cmdargc++) * sizeof(char *) ); + cmdargs=malloc( (cmdargc+1) * sizeof(char *) ); cmdargs[0]=strdup("initlog"); - for (x=0;x<(cmdargc-1);x++) { - cmdargs[x+1]=tmpargs[x]; + for (z=0;z<(cmdargc);z++) { + cmdargs[z+1]=tmpargs[z]; } processArgs(cmdargc,cmdargs,1); } @@ -175,7 +178,6 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, } if ((!WIFEXITED(rc)) || (rc=WEXITSTATUS(rc))) { /* If there was an error and we're quiet, be loud */ - int x; if (quiet && output) { buf=calloc(2048,sizeof(char)); -- cgit v1.2.1