[PATCH] scripts/kconfig/conf segfaults without filename

From: $B5HF#1QL@(
Date: Fri Jun 06 2003 - 10:11:41 EST


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 <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jun 07 2003 - 22:00:30 EST