aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-10-27 12:58:33 +0100
committerMichael Brown <mcb30@ipxe.org>2022-10-27 13:05:35 +0100
commitf48b01cb016921cf0f58bd6be676c17042923719 (patch)
tree69a56b014a97ebeea5bca17618246fe1c96a0d39
parent8fce26730c4df7a9792bb144c75c2c5b998c91af (diff)
downloadipxe-vgafix.zip
ipxe-vgafix.tar.gz
ipxe-vgafix.tar.bz2
[bzimage] Fix parsing of "vga=..." when not at end of command linevgafix
bzimage_parse_cmdline() uses strcmp() to identify the named "vga=..." kernel command line option values, which will give a false negative if the option is not last on the command line. Fix by temporarily changing the relevant command line separator (if any) to a NUL terminator. Debugged-by: Simon Rettberg <simon.rettberg@rz.uni-freiburg.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/arch/x86/image/bzimage.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c
index a782127..769e0c9 100644
--- a/src/arch/x86/image/bzimage.c
+++ b/src/arch/x86/image/bzimage.c
@@ -252,13 +252,17 @@ static void bzimage_update_header ( struct image *image,
*/
static int bzimage_parse_cmdline ( struct image *image,
struct bzimage_context *bzimg,
- const char *cmdline ) {
+ char *cmdline ) {
+ char *sep;
char *vga;
char *mem;
/* Look for "vga=" */
if ( ( vga = strstr ( cmdline, "vga=" ) ) ) {
vga += 4;
+ sep = strchr ( vga, ' ' );
+ if ( sep )
+ *sep = '\0';
if ( strcmp ( vga, "normal" ) == 0 ) {
bzimg->vid_mode = BZI_VID_MODE_NORMAL;
} else if ( strcmp ( vga, "ext" ) == 0 ) {
@@ -267,11 +271,13 @@ static int bzimage_parse_cmdline ( struct image *image,
bzimg->vid_mode = BZI_VID_MODE_ASK;
} else {
bzimg->vid_mode = strtoul ( vga, &vga, 0 );
- if ( *vga && ( *vga != ' ' ) ) {
- DBGC ( image, "bzImage %p strange \"vga=\""
+ if ( *vga ) {
+ DBGC ( image, "bzImage %p strange \"vga=\" "
"terminator '%c'\n", image, *vga );
}
}
+ if ( sep )
+ *sep = ' ';
}
/* Look for "mem=" */
@@ -522,7 +528,7 @@ static void bzimage_load_initrds ( struct image *image,
*/
static int bzimage_exec ( struct image *image ) {
struct bzimage_context bzimg;
- const char *cmdline = ( image->cmdline ? image->cmdline : "" );
+ char *cmdline = ( image->cmdline ? image->cmdline : "" );
int rc;
/* Read and parse header from image */