Cope with system("").
This commit is contained in:
parent
69b9048e1a
commit
0a26cd2933
|
@ -48,14 +48,20 @@ static struct command commands_end[0] __table_end ( commands );
|
||||||
*/
|
*/
|
||||||
int execv ( const char *command, char * const argv[] ) {
|
int execv ( const char *command, char * const argv[] ) {
|
||||||
struct command *cmd;
|
struct command *cmd;
|
||||||
int argc = 0;
|
int argc;
|
||||||
|
|
||||||
assert ( argv[0] != NULL );
|
|
||||||
|
|
||||||
/* Count number of arguments */
|
/* Count number of arguments */
|
||||||
do {
|
for ( argc = 0 ; argv[argc] ; argc++ ) {}
|
||||||
argc++;
|
|
||||||
} while ( argv[argc] != NULL );
|
/* 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
|
/* Reset getopt() library ready for use by the command. This
|
||||||
* is an artefact of the POSIX getopt() API within the context
|
* is an artefact of the POSIX getopt() API within the context
|
||||||
|
|
Reference in New Issue