diff options
author | Michael Brown <mcb30@etherboot.org> | 2008-06-12 02:12:10 +0100 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2008-06-12 02:12:10 +0100 |
commit | 4c8501796877e66b0487d776431c92ee8141f6b6 (patch) | |
tree | afcddc9f65d46efef109f1e9a06e914981674309 /src/hci/commands/image_cmd.c | |
parent | 031b30898a098d7bb2d2d14a7639ed060274528a (diff) | |
download | ipxe-4c8501796877e66b0487d776431c92ee8141f6b6.tar.gz |
[cmdline] Remove arbitrary limit on the length of image command lines
Diffstat (limited to 'src/hci/commands/image_cmd.c')
-rw-r--r-- | src/hci/commands/image_cmd.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index 44689dd2b..23843a7e4 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] ); + } } /** |