lkml.org 
[lkml]   [2000]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Subjecta bug in the command-line parser
From
Date
  I found a bug in the command-line parser, parse_options in
init/main.c. I examined only 2.2.16 and 2.2.17, but there might remain
the same problem in 2.4.0-test?.

The phenomenon is that argv_init becomes {"init", "", NULL}, when
one inputs a command-line like:

root=/dev/ram ro
^^
two spaces

This is harmful for some shell programs. You might think he just
need to be careful enough not to insert multiple spaces between two
options, but things are not so trivial. On i386 (I haven't tested any
other architecture), "mem=XXX" is handled in arch/i386/kernel/setup.c
but the function setup_arch doesn't remove any space after the option
correctly, so if the user enters "mem=128M root=/dev/hda", the string
command_line returned by the function setup_arch will be
" root=/dev/hda" instead of "root=/dev/hda", and then argv_init will
be {"init", "", NULL}, even though the user doesn't input multiple
spaces.

It is possible to avoid this problem in boot loaders (yes, in fact,
I did in GRUB), but I think it would be better to fix the bug itself
in Linux. Thus, I propose this simple patch:

*** linux-2.2.17.orig/init/main.c Tue Sep 5 02:39:28 2000
--- linux-2.2.17/init/main.c Tue Sep 12 06:02:34 2000
***************
*** 1254,1259 ****
--- 1254,1262 ----
}
if (next != NULL)
*next++ = 0;
+ if (!*line)
+ continue;
+
/*
* check for kernel options first..
*/


Thanks,
Okuji
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.030 / U:1.008 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site