32 lines
1.2 KiB
Diff
32 lines
1.2 KiB
Diff
|
Based on 4212a3375e03fd12cb407b34cab59dbe4ed9f4eb Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||
|
Date: Sun, 3 Aug 2014 01:28:21 -0400
|
||
|
Subject: [PATCH] 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.
|
||
|
---
|
||
|
src/nspawn/nspawn.c | 8 ++------
|
||
|
1 file changed, 2 insertions(+), 6 deletions(-)
|
||
|
|
||
|
--- src/nspawn/nspawn.c
|
||
|
+++ src/nspawn/nspawn.c 2014-08-22 10:18:20.390235611 +0000
|
||
|
@@ -1383,12 +1383,8 @@ static int setup_veth(pid_t pid, char if
|
||
|
|
||
|
/* 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 = sd_rtnl_open(&rtnl, 0);
|
||
|
if (r < 0) {
|