[libvirt] [PATCH] Fix activeDomainList handling

# HG changeset patch # User john.levon@sun.com # Date 1231958879 28800 # Node ID 1fca4b0dd4c6ab3c0030b4986de6fe5cb7c94631 # Parent 097f5b4497d7ecc5cce14d10559244313d26ce46 Fix activeDomainList handling It must be NULLed out after free()ing. Signed-off-by: John Levon <john.levon@sun.com> diff --git a/src/xs_internal.c b/src/xs_internal.c --- a/src/xs_internal.c +++ b/src/xs_internal.c @@ -388,8 +388,10 @@ xenStoreClose(virConnectPtr conn) } xenStoreWatchListFree(priv->xsWatchList); + priv->xsWatchList = NULL; #ifndef PROXY xenUnifiedDomainInfoListFree(activeDomainList); + activeDomainList = NULL; #endif if (priv->xshandle == NULL) return(-1);

On Wed, Jan 14, 2009 at 10:53:51AM -0800, john.levon@sun.com wrote:
Fix activeDomainList handling
It must be NULLed out after free()ing.
This one is incomplete - I didn't find the bug since I have to use 0@0.so with LIBVIRT_DEBUG. Annoyingly, Solaris printf requires %s parameters to not be NULL, and the debug messages use this Linux feature in several places... new patch soon regards john

John Levon <levon@movementarian.org> wrote:
On Wed, Jan 14, 2009 at 10:53:51AM -0800, john.levon@sun.com wrote:
Fix activeDomainList handling
It must be NULLed out after free()ing.
This one is incomplete - I didn't find the bug since I have to use 0@0.so with LIBVIRT_DEBUG. Annoyingly, Solaris printf requires %s parameters to not be NULL, and the debug messages use this Linux feature in several places... new patch soon
That glibc's printf functions accept a NULL parameter for a %s format directive is a *mis*feature. As such, I think any code that relies on it is buggy, so patches would be most welcome.

On Wed, Jan 14, 2009 at 08:27:36PM +0100, Jim Meyering wrote:
John Levon <levon@movementarian.org> wrote:
On Wed, Jan 14, 2009 at 10:53:51AM -0800, john.levon@sun.com wrote:
Fix activeDomainList handling
It must be NULLed out after free()ing.
This one is incomplete - I didn't find the bug since I have to use 0@0.so with LIBVIRT_DEBUG. Annoyingly, Solaris printf requires %s parameters to not be NULL, and the debug messages use this Linux feature in several places... new patch soon
That glibc's printf functions accept a NULL parameter for a %s format directive is a *mis*feature. As such, I think any code that relies on it is buggy, so patches would be most welcome.
Some kind of macro to make it easy to pass params to %s args would make this less tedious to fix / easier to check #define nonnull(str) ((str) ? (str) : "<null>") 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 :|

john.levon@sun.com wrote:
Fix activeDomainList handling
In your eventual ChangeLog entry, please mention xsWatchList, too.
It must be NULLed out after free()ing.
Signed-off-by: John Levon <john.levon@sun.com>
diff --git a/src/xs_internal.c b/src/xs_internal.c --- a/src/xs_internal.c +++ b/src/xs_internal.c @@ -388,8 +388,10 @@ xenStoreClose(virConnectPtr conn) }
xenStoreWatchListFree(priv->xsWatchList); + priv->xsWatchList = NULL; #ifndef PROXY xenUnifiedDomainInfoListFree(activeDomainList); + activeDomainList = NULL; #endif if (priv->xshandle == NULL) return(-1);
Definitely good fixes. Otherwise we'd end up dereferencing freed pointers. However these conflict with Dan's recent changes, so you should wait to hear from him.

On Wed, Jan 14, 2009 at 10:53:51AM -0800, john.levon@sun.com wrote:
# HG changeset patch # User john.levon@sun.com # Date 1231958879 28800 # Node ID 1fca4b0dd4c6ab3c0030b4986de6fe5cb7c94631 # Parent 097f5b4497d7ecc5cce14d10559244313d26ce46 Fix activeDomainList handling
It must be NULLed out after free()ing.
Signed-off-by: John Levon <john.levon@sun.com>
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 :|
participants (4)
-
Daniel P. Berrange
-
Jim Meyering
-
John Levon
-
john.levon@sun.com