From: Michael Brown Date: Fri, 8 Dec 2006 17:07:12 +0000 (+0000) Subject: Cope with system(""). X-Git-Tag: v0.9.3~929 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a26cd293384910fa1f914f6900c96432dcd35e7;p=thirdparty%2Fipxe.git Cope with system(""). --- diff --git a/src/core/exec.c b/src/core/exec.c index dee814499..73f111eed 100644 --- a/src/core/exec.c +++ b/src/core/exec.c @@ -48,14 +48,20 @@ static struct command commands_end[0] __table_end ( commands ); */ int execv ( const char *command, char * const argv[] ) { struct command *cmd; - int argc = 0; - - assert ( argv[0] != NULL ); + int argc; /* Count number of arguments */ - do { - argc++; - } while ( argv[argc] != NULL ); + for ( argc = 0 ; argv[argc] ; argc++ ) {} + + /* Sanity checks */ + if ( ! command ) { + DBG ( "No command\n" ); + return -EINVAL; + } + if ( ! argc ) { + DBG ( "%s: empty argument list\n", command ); + return -EINVAL; + } /* Reset getopt() library ready for use by the command. This * is an artefact of the POSIX getopt() API within the context