[patch] fix modprobe segfault without args

Timo Teräs timo.teras at iki.fi
Wed Oct 29 14:45:00 UTC 2008


Hi,

The new modprobe stuff does not handle properly the case if no arguments at all
is passed. The patch below fixes it.

--- modutils/modprobe.c	(revision 23853)
+++ modutils/modprobe.c	(working copy)
@@ -222,15 +222,14 @@
 	uname(&uts);
 	xchdir(uts.release);
 
-	if (option_mask32 & (MODPROBE_OPT_REMOVE | MODPROBE_OPT_INSERT_ALL)) {
-		/* each parameter is a module name */
-		num_modules = argc;
-		if (num_modules == 0) {
+	num_modules = argc;
+	if (num_modules == 0) {
+		if (option_mask32 & MODPROBE_OPT_REMOVE) {
 			if (bb_delete_module(NULL, O_NONBLOCK|O_EXCL) != 0)
 				bb_perror_msg_and_die("rmmod");
 			return EXIT_SUCCESS;
 		}
-	} else {
+	} else if (!(option_mask32 & MODPROBE_OPT_INSERT_ALL)) {
 		/* the only module, the rest of parameters are options */
 		num_modules = 1;
 		add_option(&options, NULL, parse_cmdline_module_options(argv));



More information about the busybox mailing list