Re: [PATCH] storage: fix bogus target in gluster volume xml

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

 



On 12/19/2013 02:18 AM, Peter Krempa wrote:
> On 12/19/13 05:38, Eric Blake wrote:
>> 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.
>>

> 
> ... you still need to free state->uri->path before you overwrite it with
> the previous value that is temporarily stored in 'tmp' a few lines below:
> 
>     tmp = state->uri->path;
>     if (virAsprintf(&vol->key, "%s%s", state->uri->path, name) < 0) {
>         state->uri->path = tmp;
>         goto cleanup;
>     }
>     if (!(vol->target.path = virURIFormat(state->uri))) {
>         state->uri->path = tmp;
>         goto cleanup;
>     }
>     state->uri->path = tmp; <--- here
> 
> ACK with the memleak resolved.

A demonstration of how NOT to write patches late at night.  Thanks for
catching that; pushing with this squashed in.

diff --git i/src/storage/storage_backend_gluster.c
w/src/storage/storage_backend_gluster.c
index 9aa692e..2ec2424 100644
--- i/src/storage/storage_backend_gluster.c
+++ w/src/storage/storage_backend_gluster.c
@@ -232,9 +232,11 @@
virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
         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)) {

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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