]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[image] Clear the command line rather than setting an empty command line
authorMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2011 02:44:24 +0000 (02:44 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2011 02:44:24 +0000 (02:44 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/hci/commands/image_cmd.c

index 9b3895a9f3b1a71adf50e40170795f6cc583937f..7001087b6ec65f618f117b4588d831e3199c1947 100644 (file)
@@ -45,13 +45,16 @@ FILE_LICENCE ( GPL2_OR_LATER );
  */
 static int imgfill_cmdline ( struct image *image, unsigned int nargs, 
                             char **args ) {
-       size_t len;
+       size_t len = 0;
        unsigned int i;
 
+       /* Clear command line if no arguments given */
+       if ( ! nargs )
+               return image_set_cmdline ( image, NULL );
+
        /* Determine total length of command line */
-       len = 1; /* NUL */
        for ( i = 0 ; i < nargs ; i++ )
-               len += ( 1 /* possible space */ + strlen ( args[i] ) );
+               len += ( strlen ( args[i] ) + 1 /* space or NUL */ );
 
        {
                char buf[len];