]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
fixed SegFault in virauth
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 24 Jul 2012 14:08:46 +0000 (16:08 +0200)
committerCole Robinson <crobinso@redhat.com>
Mon, 13 Aug 2012 01:15:46 +0000 (21:15 -0400)
No check for conn->uri being NULL in virAuthGetConfigFilePath (valid
state) made the client segfault. This happens for example with these
settings:
 - no virtualbox driver installed (modifies conn->uri)
 - no default URI set (VIRSH_DEFAULT_CONNECT_URI="",
   LIBVIRT_DEFAULT_URI="", uri_default="")
 - auth_sock_rw="sasl"
 - virsh run as root

That are unfortunately the settings with fresh Fedora 17 installation
with VDSM.

The check ought to be enough as conn->uri being NULL is valid in later
code and is handled properly.
(cherry picked from commit 5eef74320b0bb9e604400168e0896c5ac527abef)

src/util/virauth.c

index c59c55adc344bad8a288bfe63b1e6939a60b0b9e..3ece47147e3157b0f92a1d8343eb412e67b1fee1 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * virauth.c: authentication related utility functions
  *
+ * Copyright (C) 2012 Red Hat, Inc.
  * Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.com>
  *
  * This library is free software; you can redistribute it and/or
@@ -54,14 +55,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;
+            }
         }
     }