[PATCH 8/9] switch_root: use snprintf() rather tan str{cpy,cat}()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>
---
 sys-utils/switch_root.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index cb89431..5356c19 100644
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -2,6 +2,7 @@
  * switchroot.c - switch to new root directory and start init.
  *
  * Copyright 2002-2008 Red Hat, Inc.  All rights reserved.
+ * Copyright (C) 2009 Karel Zak <kzak@xxxxxxxxxx>
  *
  * 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
@@ -114,8 +115,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);
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux