]> err.no Git - util-linux/commitdiff
switch_root: use snprintf() rather tan str{cpy,cat}()
authorKarel Zak <kzak@redhat.com>
Tue, 9 Jun 2009 14:35:07 +0000 (16:35 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Jun 2009 19:30:47 +0000 (21:30 +0200)
Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/switch_root.c

index 14d2916bfa1cf25c3ce9970a9baa8c508169ec0e..8daacb1d0e85bdc0be77e680df7ad65048c4b75b 100644 (file)
@@ -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);