summaryrefslogtreecommitdiffstats
path: root/sys-utils/switch_root.c
diff options
context:
space:
mode:
authorKarel Zak2009-06-09 16:35:07 +0200
committerKarel Zak2009-06-22 21:30:47 +0200
commit8f24e52ed75ea16962a40a9628ae9ef85a2d034c (patch)
treef47203cb28e2269b76bd54814c5e4f394eca891e /sys-utils/switch_root.c
parentswitch_root: clean up argv[] usage, add -h and -V (diff)
downloadkernel-qcow2-util-linux-8f24e52ed75ea16962a40a9628ae9ef85a2d034c.tar.gz
kernel-qcow2-util-linux-8f24e52ed75ea16962a40a9628ae9ef85a2d034c.tar.xz
kernel-qcow2-util-linux-8f24e52ed75ea16962a40a9628ae9ef85a2d034c.zip
switch_root: use snprintf() rather tan str{cpy,cat}()
Signed-off-by: Peter Jones <pjones@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/switch_root.c')
-rw-r--r--sys-utils/switch_root.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index 14d2916bf..8daacb1d0 100644
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -1,7 +1,7 @@
/*
* switchroot.c - switch to new root directory and start init.
*
- * Copyright 2002-2008 Red Hat, Inc. All rights reserved.
+ * Copyright 2002-2009 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -113,8 +113,9 @@ static int switchroot(const char *newroot)
for (i = 0; umounts[i] != NULL; i++) {
char newmount[PATH_MAX];
- strcpy(newmount, newroot);
- strcat(newmount, umounts[i]);
+
+ snprintf(newmount, sizeof(newmount), "%s%s", newroot, umounts[i]);
+
if (mount(umounts[i], newmount, NULL, MS_MOVE, NULL) < 0) {
warn("failed to mount moving %s to %s",
umounts[i], newmount);