Browse Source

[prefix] Cope with BOOT_IMAGE= anywhere within command line

Some bootloaders seem to add "BOOT_IMAGE=..." at the end of the
command line; some at the start.  Cope with either variation.

Reported-by: Dave Hansen <dave@sr71.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
be600ed996
1 changed files with 14 additions and 4 deletions
  1. 14
    4
      src/arch/i386/core/cmdline.c

+ 14
- 4
src/arch/i386/core/cmdline.c View File

@@ -66,7 +66,8 @@ static void cmdline_init ( void ) {
66 66
 	struct image *image = &cmdline_image;
67 67
 	userptr_t cmdline_user;
68 68
 	char *cmdline;
69
-	char *tmp;
69
+	char *boot_image;
70
+	char *boot_image_end;
70 71
 	size_t len;
71 72
 
72 73
 	/* Do nothing if no command line was specified */
@@ -91,9 +92,18 @@ static void cmdline_init ( void ) {
91 92
 	/* Check for unwanted cruft in the command line */
92 93
 	while ( isspace ( *cmdline ) )
93 94
 		cmdline++;
94
-	if ( ( tmp = strstr ( cmdline, "BOOT_IMAGE=" ) ) != NULL ) {
95
-		DBGC ( image, "CMDLINE stripping \"%s\"\n", tmp );
96
-		*tmp = '\0';
95
+	if ( ( boot_image = strstr ( cmdline, "BOOT_IMAGE=" ) ) != NULL ) {
96
+		boot_image_end = strchr ( boot_image, ' ' );
97
+		if ( boot_image_end ) {
98
+			*boot_image_end = '\0';
99
+			DBGC ( image, "CMDLINE stripping \"%s\"\n",
100
+			       boot_image );
101
+			strcpy ( boot_image, ( boot_image_end + 1 ) );
102
+		} else {
103
+			DBGC ( image, "CMDLINE stripping \"%s\"\n",
104
+			       boot_image );
105
+			*boot_image = '\0';
106
+		}
97 107
 	}
98 108
 	DBGC ( image, "CMDLINE using \"%s\"\n", cmdline );
99 109
 

Loading…
Cancel
Save