summaryrefslogtreecommitdiffstats
path: root/src/hci/commands
diff options
context:
space:
mode:
authorMichael Brown2008-06-12 03:12:10 +0200
committerMichael Brown2008-06-12 03:12:10 +0200
commit4c8501796877e66b0487d776431c92ee8141f6b6 (patch)
treeafcddc9f65d46efef109f1e9a06e914981674309 /src/hci/commands
parent[smbios] Fix SMBIOS string fetching (diff)
downloadipxe-4c8501796877e66b0487d776431c92ee8141f6b6.tar.gz
ipxe-4c8501796877e66b0487d776431c92ee8141f6b6.tar.xz
ipxe-4c8501796877e66b0487d776431c92ee8141f6b6.zip
[cmdline] Remove arbitrary limit on the length of image command lines
Diffstat (limited to 'src/hci/commands')
-rw-r--r--src/hci/commands/image_cmd.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c
index 44689dd2..23843a7e 100644
--- a/src/hci/commands/image_cmd.c
+++ b/src/hci/commands/image_cmd.c
@@ -49,16 +49,25 @@ enum image_action {
*/
static int imgfill_cmdline ( struct image *image, unsigned int nargs,
char **args ) {
- char buf[256];
- size_t used = 0;
+ size_t len;
+ unsigned int i;
- memset ( buf, 0, sizeof ( buf ) );
- while ( ( used < sizeof ( buf ) ) && nargs-- ) {
- used += snprintf ( &buf[used], ( sizeof ( buf ) - used ),
- " %s", *(args++) );
- }
+ /* Determine total length of command line */
+ len = 1; /* NUL */
+ for ( i = 0 ; i < nargs ; i++ )
+ len += ( 1 /* space */ + strlen ( args[i] ) );
+
+ {
+ char buf[len];
+ char *ptr = buf;
- return image_set_cmdline ( image, &buf[1] );
+ /* Assemble command line */
+ for ( i = 0 ; i < nargs ; i++ )
+ ptr += sprintf ( ptr, " %s", args[i] );
+ assert ( ptr == ( buf + len - 1 ) );
+
+ return image_set_cmdline ( image, &buf[1] );
+ }
}
/**