render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 531fd52a6d5dc3ccfc2370ff7c3cd8b44e2a93ab Mon Sep 17 00:00:00 2001
Message-Id: <531fd52a6d5dc3ccfc2370ff7c3cd8b44e2a93ab@dist-git>
From: Eric Blake <eblake@redhat.com>
Date: Wed, 26 Feb 2014 14:55:15 +0100
Subject: [PATCH] storage: fix bogus target in gluster volume xml

https://bugzilla.redhat.com/show_bug.cgi?id=1032370

Commit 6cd60b6 was flat out broken - it tried to print into the
wrong variable.  My testing was obviously too cursory (did the
name get a slash added?); valgrind would have caught the error.
Thankfully it didn't hit any release.

Reported by Peter Krempa.

* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Fix bogus code.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 3a96cebceb1d82cc550bef59250c7da02ac92707)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/storage/storage_backend_gluster.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 622526b..2ec2424 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -227,14 +227,16 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
         goto cleanup;
 
     tmp = state->uri->path;
-    if (virAsprintf(&vol->key, "%s%s", state->uri->path, name) < 0) {
+    if (virAsprintf(&state->uri->path, "/%s", vol->key) < 0) {
         state->uri->path = tmp;
         goto cleanup;
     }
     if (!(vol->target.path = virURIFormat(state->uri))) {
+        VIR_FREE(state->uri->path);
         state->uri->path = tmp;
         goto cleanup;
     }
+    VIR_FREE(state->uri->path);
     state->uri->path = tmp;
 
     if (S_ISDIR(st->st_mode)) {
-- 
1.9.0