[libvirt] [PATCH] fixed segfault in virauth

No check for conn->uri being NULL in virAuthGetConfigFilePath (valid state) made the client segfault. This happens with fresh defalt VDSM configuration for example. The check ought to be enough as conn->uri being NULL is valid in later code. --- src/util/virauth.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/util/virauth.c b/src/util/virauth.c index e6b1db0..2c1a4ae 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -1,7 +1,7 @@ /* * virauth.c: authentication related utility functions * - * Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.com> + * Copyright (C) 2010, 2012 Matthias Bolte <matthias.bolte@googlemail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -54,14 +54,16 @@ int virAuthGetConfigFilePath(virConnectPtr conn, return 0; } - for (i = 0 ; i < conn->uri->paramsCount ; i++) { - if (STREQ_NULLABLE(conn->uri->params[i].name, "authfile") && - conn->uri->params[i].value) { - VIR_DEBUG("Using path from URI '%s'", - conn->uri->params[i].value); - if (!(*path = strdup(conn->uri->params[i].value))) - goto no_memory; - return 0; + if (conn && conn->uri) { + for (i = 0 ; i < conn->uri->paramsCount ; i++) { + if (STREQ_NULLABLE(conn->uri->params[i].name, "authfile") && + conn->uri->params[i].value) { + VIR_DEBUG("Using path from URI '%s'", + conn->uri->params[i].value); + if (!(*path = strdup(conn->uri->params[i].value))) + goto no_memory; + return 0; + } } } -- 1.7.8.6

On 07/23/2012 12:51 PM, Martin Kletzander wrote:
No check for conn->uri being NULL in virAuthGetConfigFilePath (valid state) made the client segfault. This happens with fresh defalt VDSM configuration for example.
The check ought to be enough as conn->uri being NULL is valid in later code. --- src/util/virauth.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/util/virauth.c b/src/util/virauth.c index e6b1db0..2c1a4ae 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -1,7 +1,7 @@ /* * virauth.c: authentication related utility functions * - * Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.com> + * Copyright (C) 2010, 2012 Matthias Bolte <matthias.bolte@googlemail.com>
Wrong copyright attribution. ACK once you fix that. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Mon, Jul 23, 2012 at 08:51:23PM +0200, Martin Kletzander wrote:
No check for conn->uri being NULL in virAuthGetConfigFilePath (valid state) made the client segfault. This happens with fresh defalt VDSM configuration for example.
Line wrap the commit message please.
The check ought to be enough as conn->uri being NULL is valid in later code.
Can you explain a little further just what scenario leads to this happening. In my tests with a NULL URI I don't see a crash.
--- src/util/virauth.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/util/virauth.c b/src/util/virauth.c index e6b1db0..2c1a4ae 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -1,7 +1,7 @@ /* * virauth.c: authentication related utility functions * - * Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.com> + * Copyright (C) 2010, 2012 Matthias Bolte <matthias.bolte@googlemail.com>
I'm pretty sure you're not Matthias, so you shouldn't be changing this, rather adding in a Red Hat copyright.
* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -54,14 +54,16 @@ int virAuthGetConfigFilePath(virConnectPtr conn, return 0; }
- for (i = 0 ; i < conn->uri->paramsCount ; i++) { - if (STREQ_NULLABLE(conn->uri->params[i].name, "authfile") && - conn->uri->params[i].value) { - VIR_DEBUG("Using path from URI '%s'", - conn->uri->params[i].value); - if (!(*path = strdup(conn->uri->params[i].value))) - goto no_memory; - return 0; + if (conn && conn->uri) { + for (i = 0 ; i < conn->uri->paramsCount ; i++) { + if (STREQ_NULLABLE(conn->uri->params[i].name, "authfile") && + conn->uri->params[i].value) { + VIR_DEBUG("Using path from URI '%s'", + conn->uri->params[i].value); + if (!(*path = strdup(conn->uri->params[i].value))) + goto no_memory; + return 0; + } } }
Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Martin Kletzander