From bd01ccfc5141c1fa954348dcb19020dd45678aad Mon Sep 17 00:00:00 2001 From: root Date: Thu, 25 Jun 2015 18:33:08 +0000 Subject: [PATCH] URI handling was broken for anything containing a query string. URI's should not be escaped before being handed to QEMU. The "path" returned by the libxml2 URI libary is insufficient. The query string portion of the URI must also be concatenated. --- fish/uri.c | 19 +++++++++---------- src/launch-direct.c | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fish/uri.c b/fish/uri.c index 593e62a..1566cdf 100644 --- a/fish/uri.c +++ b/fish/uri.c @@ -178,12 +178,20 @@ parse (const char *arg, char **path_ret, char **protocol_ret, } } + if (asprintf(&path, "%s?%s", uri->path, uri->query_raw) == -1) { + perror ("asprintf: path + query_raw"); + free (*protocol_ret); + guestfs_int_free_string_list (*server_ret); + free (*username_ret); + free (*password_ret); + return -1; + } + /* We may have to adjust the path depending on the protocol. For * example ceph/rbd URIs look like rbd:///pool/disk, but the * exportname expected will be "pool/disk". Here, uri->path will be * "/pool/disk" so we have to knock off the leading '/' character. */ - path = uri->path; if (path && path[0] == '/' && (STREQ (uri->scheme, "gluster") || STREQ (uri->scheme, "iscsi") || @@ -192,15 +200,6 @@ parse (const char *arg, char **path_ret, char **protocol_ret, path++; *path_ret = strdup (path ? path : ""); - if (*path_ret == NULL) { - perror ("strdup: path"); - free (*protocol_ret); - guestfs_int_free_string_list (*server_ret); - free (*username_ret); - free (*password_ret); - return -1; - } - return 0; } diff --git a/src/launch-direct.c b/src/launch-direct.c index ea67ec9..cb82f20 100644 --- a/src/launch-direct.c +++ b/src/launch-direct.c @@ -1224,7 +1224,7 @@ make_uri (guestfs_h *g, const char *scheme, const char *user, break; } - return (char *) xmlSaveUri (&uri); + return xmlURIUnescapeString((char *) xmlSaveUri (&uri), -1, NULL); } /* Useful function to format a drive + protocol for qemu. Also shared -- 1.9.1