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

Peter Krempa pkrempa at redhat.com
Thu Dec 19 09:18:39 UTC 2013


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.
> 
> Reported by Peter Krempa.
> 
> * src/storage/storage_backend_gluster.c
> (virStorageBackendGlusterRefreshVol): Fix bogus code.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>  src/storage/storage_backend_gluster.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
> index 622526b..9aa692e 100644
> --- a/src/storage/storage_backend_gluster.c
> +++ b/src/storage/storage_backend_gluster.c
> @@ -227,7 +227,7 @@ 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) {

Ok, but ...

>          state->uri->path = tmp;
>          goto cleanup;
>      }
> 

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

Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131219/4b39044d/attachment-0001.sig>


More information about the libvir-list mailing list