|
@@ -55,18 +55,21 @@ static int imgfill_cmdline ( struct image *image, unsigned int nargs,
|
55
|
55
|
/* Determine total length of command line */
|
56
|
56
|
len = 1; /* NUL */
|
57
|
57
|
for ( i = 0 ; i < nargs ; i++ )
|
58
|
|
- len += ( 1 /* space */ + strlen ( args[i] ) );
|
|
58
|
+ len += ( 1 /* possible space */ + strlen ( args[i] ) );
|
59
|
59
|
|
60
|
60
|
{
|
61
|
61
|
char buf[len];
|
62
|
62
|
char *ptr = buf;
|
63
|
63
|
|
64
|
64
|
/* Assemble command line */
|
65
|
|
- for ( i = 0 ; i < nargs ; i++ )
|
66
|
|
- ptr += sprintf ( ptr, " %s", args[i] );
|
67
|
|
- assert ( ptr == ( buf + len - 1 ) );
|
|
65
|
+ buf[0] = '\0';
|
|
66
|
+ for ( i = 0 ; i < nargs ; i++ ) {
|
|
67
|
+ ptr += sprintf ( ptr, "%s%s", ( i ? " " : "" ),
|
|
68
|
+ args[i] );
|
|
69
|
+ }
|
|
70
|
+ assert ( ptr < ( buf + len ) );
|
68
|
71
|
|
69
|
|
- return image_set_cmdline ( image, &buf[1] );
|
|
72
|
+ return image_set_cmdline ( image, buf );
|
70
|
73
|
}
|
71
|
74
|
}
|
72
|
75
|
|