Hello.

scripts/kconfig/conf does not check number of command line arguments 
properly, and it segfaults if it is invoked without filename.

Thanks in advance.

Index: linux25/scripts/kconfig/conf.c
===================================================================
RCS file: /cvsroot/usagi/usagi/kernel/linux25/scripts/kconfig/conf.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 conf.c
--- linux25/scripts/kconfig/conf.c      27 May 2003 03:01:00 -0000      1.1.1.4
+++ linux25/scripts/kconfig/conf.c      6 Jun 2003 14:54:34 -0000
@@ -476,39 +476,45 @@
        const char *name;
        struct stat tmpstat;
 
-       if (ac > 1 && av[1][0] == '-') {
-               switch (av[1][1]) {
-               case 'o':
-                       input_mode = ask_new;
-                       break;
-               case 's':
-                       input_mode = ask_silent;
-                       valid_stdin = isatty(0) && isatty(1) && isatty(2);
-                       break;
-               case 'd':
-                       input_mode = set_default;
-                       break;
-               case 'n':
-                       input_mode = set_no;
-                       break;
-               case 'm':
-                       input_mode = set_mod;
-                       break;
-               case 'y':
-                       input_mode = set_yes;
-                       break;
-               case 'r':
-                       input_mode = set_random;
-                       srandom(time(NULL));
-                       break;
-               case 'h':
-               case '?':
-                       printf("%s [-o|-s] config\n", av[0]);
-                       exit(0);
-               }
-               name = av[2];
+       if (ac > 1) {
+               if (av[1][0] == '-') {
+                       name = ac > 2 ? av[2] : NULL;
+
+                       switch (av[1][1]) {
+                       case 'o':
+                               input_mode = ask_new;
+                               break;
+                       case 's':
+                               input_mode = ask_silent;
+                               valid_stdin = isatty(0) && isatty(1) && isatty(2);
+                               break;
+                       case 'd':
+                               input_mode = set_default;
+                               break;
+                       case 'n':
+                               input_mode = set_no;
+                               break;
+                       case 'm':
+                               input_mode = set_mod;
+                               break;
+                       case 'y':
+                               input_mode = set_yes;
+                               break;
+                       case 'r':
+                               input_mode = set_random;
+                               srandom(time(NULL));
+                               break;
+                       default:
+                               name = NULL;
+                       }
+               } else
+                       name = av[1];
        } else
-               name = av[1];
+               name = NULL;
+       if (name == NULL) {
+               printf("%s [-o|-s|-d|-n|-m|-y|-r] config\n", av[0]);
+               exit(0);
+       }
        conf_parse(name);
        //zconfdump(stdout);
        switch (input_mode) {

-- 
Hideaki YOSHIFUJI @ USAGI Project <[EMAIL PROTECTED]>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA


-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
kbuild-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/kbuild-devel

Reply via email to