[lxc-devel] [PATCH] lxc-user-nic: handle failure in create_nic

Stéphane Graber stgraber at ubuntu.com
Mon Apr 28 21:03:58 UTC 2014


On Mon, Apr 28, 2014 at 04:00:06PM -0500, Serge Hallyn wrote:
> Failures were being ignored, leading up to an eventual segfault.
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/lxc_user_nic.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lxc/lxc_user_nic.c b/src/lxc/lxc_user_nic.c
> index 0e66549..1105b3d 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);
> -- 
> 1.9.1
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140428/f3d95742/attachment.sig>


More information about the lxc-devel mailing list