[klibc] [PATCH 3/8] switch_root: let the utility verify passed args

maximilian attems max at stro.at
Wed Jul 13 06:48:28 PDT 2011


We don't want to execute null strings.
Seen in util-linux switch_root().

Signed-off-by: maximilian attems <max at stro.at>
---
 usr/kinit/switch_root/switch_root.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/usr/kinit/switch_root/switch_root.c b/usr/kinit/switch_root/switch_root.c
index a422dc0..f717637 100644
--- a/usr/kinit/switch_root/switch_root.c
+++ b/usr/kinit/switch_root/switch_root.c
@@ -84,6 +84,9 @@ int main(int argc, char *argv[])
 	init = argv[optind + 1];
 	initargs = argv + optind + 1;
 
+	if (!*realroot || !*init)
+		usage();
+
 	error = switch_root(realroot, console, init, initargs);
 
 	/* If switch_root returns, something went wrong */
-- 
1.7.5.4



More information about the klibc mailing list