[BusyBox] [PATCH] debianutils/run_parts.c bug fix

Stewart Brodie stewart.brodie at pace.co.uk
Tue Jan 7 05:54:04 UTC 2003


debianutils/run_parts.c fails to zero terminate the args array it passes to
libbb/run_parts.c:run_parts if there are no -a parameters passed to
run-parts.  This causes anything from seg faults to spurious error reports
when the run_parts function tries to execv the programs.  This fault was
introduced in revision 1.2 of debianutils/run_parts.c when the functionality
was split into libbb/run_parts.c

The fix is to always zero terminate the args array (which means that it is no
longer necessary to bother terminating the array as each -a parameter is
processed either)


diff -rbu busybox.orig/debianutils/run_parts.c busybox/debianutils/run_parts.c
--- busybox.orig/debianutils/run_parts.c	Mon Nov 11 06:20:55 2002
+++ busybox/debianutils/run_parts.c	Tue Jan  7 12:45:32 2003
@@ -88,7 +88,6 @@
 			 * Called once for every argument. */
 			args = xrealloc(args, (argcount + 2) * (sizeof(char *)));
 			args[argcount++] = optarg;
-			args[argcount] = 0;
 			break;
 		default:
 			show_usage();
@@ -101,5 +100,6 @@
 	}
 
 	args[0] = argv[optind];
+	args[argcount] = 0;
 	return(run_parts(args, test_mode));
 }


-- 
Stewart Brodie, Senior Software Engineer
Pace Micro Technology PLC
645 Newmarket Road
Cambridge, CB5 8PB, United Kingdom         WWW: http://www.pacemicro.com/



More information about the busybox mailing list