Re: [PATCH 2/3] qemuBlockStorageSourceGetURI: Properly preserve query component

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

 



On Fri, Mar 27, 2020 at 16:51:20 +0100, Peter Krempa wrote:
> Look for the questionmark in the name and move the contents into the
> query portion so that we format the URI back properly.
> 
> Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> ---
>  src/qemu/qemu_block.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
> index 648c3f1026..c51fb2b6ea 100644
> --- a/src/qemu/qemu_block.c
> +++ b/src/qemu/qemu_block.c
> @@ -429,12 +429,18 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src)
>      }
> 
>      if (src->path) {
> +        char *query;
>          if (src->volume) {
>              uri->path = g_strdup_printf("/%s/%s", src->volume, src->path);
>          } else {
>              uri->path = g_strdup_printf("%s%s", src->path[0] == '/' ? "" : "/",
>                                          src->path);
>          }
> +
> +        if ((query = strchr(uri->path, '?'))) {
> +            uri->query = g_strdup(query + 1);
> +            *query = '\0';
> +        }

This would be quite fragile I'm afraid. We should only do this when we
know we got src->path from a URI with a query string, otherwise we could
find a random '?' possibly used in a file's name.

Jirka





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

  Powered by Linux