summaryrefslogtreecommitdiffstats
path: root/src/core/exec.c
diff options
context:
space:
mode:
authorMichael Brown2006-12-08 18:07:12 +0100
committerMichael Brown2006-12-08 18:07:12 +0100
commit0a26cd293384910fa1f914f6900c96432dcd35e7 (patch)
tree48412bd9f2f1e1fc651b49c7ee70de1ffc822cf7 /src/core/exec.c
parentAdded "priority" and "root-path" options (diff)
downloadipxe-0a26cd293384910fa1f914f6900c96432dcd35e7.tar.gz
ipxe-0a26cd293384910fa1f914f6900c96432dcd35e7.tar.xz
ipxe-0a26cd293384910fa1f914f6900c96432dcd35e7.zip
Cope with system("").
Diffstat (limited to 'src/core/exec.c')
-rw-r--r--src/core/exec.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/core/exec.c b/src/core/exec.c
index dee81449..73f111ee 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