[libvirt] [PATCH 5/7] lxc: avoid large stacks with veth creation

Matthias Bolte matthias.bolte at googlemail.com
Thu Sep 2 12:16:53 UTC 2010


2010/9/1 Eric Blake <eblake at redhat.com>:
> * src/lxc/veth.h (vethCreate): Change prototype.
> * src/lxc/veth.c (vethCreate): Always malloc veth2, and allocate
> veth1 if needed.
> (getFreeVethName): Adjust signature, and use virAsprintf.
> * src/lxc/lxc_driver.c (lxcSetupInterfaces): Adjust caller.
> ---
>
> This issue crossed file boundaries.  It was a bit tricky, since
> vethCreate was used in two patterns - one where the parent name was
> already known, and another where the parent name is picked as the
> first available option.  But the end result avoids strdup'ing a
> fixed-width buffer, and I think I correctly avoided any leaks (in
> lxcSetupInterfaces, once a string is transferred to *veths, then
> returning failure will cause that string to be freed in the caller).
> It also gets rid of a PATH_MAX stack over-allocation.
>

Looks good, ACK.

Matthias




More information about the libvir-list mailing list