[libvirt] [PATCH] storage_backend_fs: avoid NULL dereference on opendir failure

Daniel P. Berrange berrange at redhat.com
Wed Sep 2 10:38:57 UTC 2009


On Wed, Sep 02, 2009 at 10:05:03AM +0200, Jim Meyering wrote:
> >From 7f453c68bc709d542e4c40a388c92c7969ad0a3a Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at redhat.com>
> Date: Wed, 2 Sep 2009 09:58:50 +0200
> Subject: [PATCH 3/4] lxc: avoid NULL dereference when we find no mount point
> 
> * src/lxc_container.c (lxcContainerUnmountOldFS): Don't pass
> a NULL pointer to qsort.
> ---
>  src/lxc_container.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc_container.c b/src/lxc_container.c
> index 950dd50..2073864 100644
> --- a/src/lxc_container.c
> +++ b/src/lxc_container.c
> @@ -546,8 +546,9 @@ static int lxcContainerUnmountOldFS(void)
>      }
>      endmntent(procmnt);
> 
> -    qsort(mounts, nmounts, sizeof(mounts[0]),
> -          lxcContainerChildMountSort);
> +    if (mounts)
> +        qsort(mounts, nmounts, sizeof(mounts[0]),
> +              lxcContainerChildMountSort);
> 
>      for (i = 0 ; i < nmounts ; i++) {
>          VIR_DEBUG("Umount %s", mounts[i]);

This would is impossible to hit, since you must at least have a /proc
filesystem if we've got this far, but doesn't hurt to check anyway :-)

ACK

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list