From: Serge Hallyn Date: Mon, 28 Apr 2014 20:52:08 +0000 (-0500) Subject: lxc-user-nic: handle failure in create_nic X-Git-Tag: lxc-1.1.0.alpha1~139 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0566914c24142f6b2d1e24e4be61353d2f74f3e;p=thirdparty%2Flxc.git lxc-user-nic: handle failure in create_nic Failures were being ignored, leading up to an eventual segfault. Signed-off-by: Serge Hallyn Acked-by: Stéphane Graber --- diff --git a/src/lxc/lxc_user_nic.c b/src/lxc/lxc_user_nic.c index 0e665495b..1105b3d0e 100644 --- a/src/lxc/lxc_user_nic.c +++ b/src/lxc/lxc_user_nic.c @@ -286,13 +286,16 @@ out_del: * *dest will container the name (vethXXXXXX) which is attached * on the host to the lxc bridge */ -static void get_new_nicname(char **dest, char *br, int pid, char **cnic) +static bool get_new_nicname(char **dest, char *br, int pid, char **cnic) { char template[IFNAMSIZ]; snprintf(template, sizeof(template), "vethXXXXXX"); *dest = lxc_mkifname(template); - create_nic(*dest, br, pid, cnic); + if (!create_nic(*dest, br, pid, cnic)) { + return false; + } + return true; } static bool get_nic_from_line(char *p, char **nic) @@ -419,7 +422,8 @@ static bool get_nic_if_avail(int fd, char *me, int pid, char *intype, char *br, return false; } - get_new_nicname(nicname, br, pid, cnic); + if (!get_new_nicname(nicname, br, pid, cnic)) + return false; /* me ' ' intype ' ' br ' ' *nicname + '\n' + '\0' */ slen = strlen(me) + strlen(intype) + strlen(br) + strlen(*nicname) + 5; newline = alloca(slen);