Re: [PATCH] Avoid closing uninitialized FDs when LXC startup fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/13/2013 11:32 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> If an LXC domain failed to start because of a bogus SELinux
> label, virLXCProcessStart would call VIR_CLOSE(0) by mistake.
> This is because the code which initializes the member of the
> ttyFDs array to -1 got moved too far away from the place where
> the array is first allocated.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  src/lxc/lxc_process.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

ACK.

> +    for (i = 0 ; i < vm->def->nconsoles ; i++)
> +        ttyFDs[i] = -1;

Is it any more efficient to write:

memset(ttyFDs, -1, sizeof(ttyFDs[0]) * vm->def->nconsoles);

But it's probably not a critical path, and I'm not sure the rewrite adds
any legibility, so it is probably just a premature micro-optimization.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]