[lxc-devel] [PATCH v2] fix leak when a veth.pair name is specified
Dwight Engen
dwight.engen at oracle.com
Tue Nov 5 17:26:34 UTC 2013
Please do not apply the previous version of this patch, it is wrong. I
didn't take into account that priv is a union, so priv.veth_attr.pair
is only a pointer when netdev type is VETH. The following patch works
when non-veth nics are also present.
--
Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
src/lxc/conf.c | 2 ++
src/lxc/confile.c | 14 +-------------
2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 2a47e77..c131259 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -3308,6 +3308,8 @@ static void lxc_remove_nic(struct lxc_list *it)
free(netdev->link);
if (netdev->name)
free(netdev->name);
+ if (netdev->type == LXC_NET_VETH && netdev->priv.veth_attr.pair)
+ free(netdev->priv.veth_attr.pair);
if (netdev->upscript)
free(netdev->upscript);
if (netdev->hwaddr)
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 680d260..0e0b7e8 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -453,19 +453,7 @@ static struct lxc_netdev *network_netdev(const char *key, const char *value,
static int network_ifname(char **valuep, const char *value)
{
- if (strlen(value) >= IFNAMSIZ) {
- ERROR("interface name '%s' too long (>%d)\n",
- value, IFNAMSIZ - 1);
- return -1;
- }
-
- *valuep = strdup(value);
- if (!*valuep) {
- ERROR("failed to dup string '%s'", value);
- return -1;
- }
-
- return 0;
+ return config_string_item_max(valuep, value, IFNAMSIZ);
}
#ifndef MACVLAN_MODE_PRIVATE
--
1.8.3.1
More information about the lxc-devel
mailing list