Re: [PATCH] Fix crash accessing a NULL URI when looking up auth credentials

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

 



On 09/12/12 17:41, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

When auto-probing hypervisor drivers, the conn->uri field will
initially be NULL. Care must be taken not to access members
when doing auth lookups in the config file
---
  src/remote/remote_driver.c | 2 +-
  src/util/virauth.c         | 2 +-
  src/util/viruri.h          | 2 ++
  3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index cf1f079..8c6c807 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3281,7 +3281,7 @@ static int remoteAuthFillFromConfig(virConnectPtr conn,

          if (virAuthConfigLookup(state->config,
                                  "libvirt",
-                                conn->uri->server,
+                                VIR_URI_SERVER(conn->uri),
                                  credname,
                                  &value) < 0)
              goto cleanup;
diff --git a/src/util/virauth.c b/src/util/virauth.c
index 5539c3c..ff8d0d4 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -130,7 +130,7 @@ virAuthGetCredential(virConnectPtr conn,

      if (virAuthConfigLookup(config,
                              servicename,
-                            conn->uri->server,
+                            VIR_URI_SERVER(conn->uri),
                              credname,
                              &tmp) < 0)
          goto cleanup;
diff --git a/src/util/viruri.h b/src/util/viruri.h
index 571bf3c..de927fa 100644
--- a/src/util/viruri.h
+++ b/src/util/viruri.h
@@ -60,4 +60,6 @@ char *virURIFormatParams(virURIPtr uri);

  void virURIFree(virURIPtr uri);

+#define VIR_URI_SERVER(uri) ((uri) && (uri)->server ? (uri)->server : "localhost")

This line breaks preprocessor macro indentation syntax check.

ACK with that fixed.

Peter

--
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]