summaryrefslogtreecommitdiffstats
path: root/src/nspawn
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-08-03 07:28:21 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-08-03 07:29:51 +0200
commit4212a3375e03fd12cb407b34cab59dbe4ed9f4eb (patch)
treeda931b87386eda2f71cf99afa5fc38f0c5d19a28 /src/nspawn
parentbootchart: ask for --rel when failed to initialize graph start time (diff)
downloadsystemd-4212a3375e03fd12cb407b34cab59dbe4ed9f4eb.tar.xz
systemd-4212a3375e03fd12cb407b34cab59dbe4ed9f4eb.zip
nspawn: fix truncation of machine names in interface names
Based on patch by Michael Marineau <michael.marineau@coreos.com>: When deriving the network interface name from machine name strncpy was not properly null terminating the string and the maximum string size as returned by strlen() is actually IFNAMSIZ-1, not IFNAMSIZ.
Diffstat (limited to 'src/nspawn')
-rw-r--r--src/nspawn/nspawn.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index ddf1c371a0..b118c739e8 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1659,11 +1659,8 @@ static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ], int *ifi) {
/* Use two different interface name prefixes depending whether
* we are in bridge mode or not. */
- if (arg_network_bridge)
- memcpy(iface_name, "vb-", 3);
- else
- memcpy(iface_name, "ve-", 3);
- strncpy(iface_name+3, arg_machine, IFNAMSIZ - 3);
+ snprintf(iface_name, IFNAMSIZ, "%s-%s",
+ arg_network_bridge ? "vb" : "ve", arg_machine);
r = get_mac(&mac);
if (r < 0) {