[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 14/15] block: Fix backing paths for filenames with co
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 14/15] block: Fix backing paths for filenames with colons |
Date: |
Mon, 29 May 2017 17:06:53 +0200 |
From: Max Reitz <address@hidden>
path_combine() naturally tries to preserve a protocol prefix. However,
it recognizes such a prefix by scanning for the first colon; which is
different from what path_has_protocol() does: There only is a protocol
prefix if there is a colon before the first slash.
A protocol prefix that is not recognized by path_has_protocol() is none,
and should thus not be taken as one.
Case in point, before this patch:
$ ./qemu-img create -f qcow2 -b backing.qcow2 ./top:image.qcow2
qemu-img: ./top:image.qcow2: Could not open './top:backing.qcow2':
No such file or directory
Afterwards:
$ ./qemu-img create -f qcow2 -b backing.qcow2 ./top:image.qcow2
qemu-img: ./top:image.qcow2: Could not open './backing.qcow2':
No such file or directory
Reported-by: yangyang <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/block.c b/block.c
index 50ba264..b72b872 100644
--- a/block.c
+++ b/block.c
@@ -163,11 +163,16 @@ void path_combine(char *dest, int dest_size,
if (path_is_absolute(filename)) {
pstrcpy(dest, dest_size, filename);
} else {
- p = strchr(base_path, ':');
- if (p)
- p++;
- else
- p = base_path;
+ const char *protocol_stripped = NULL;
+
+ if (path_has_protocol(base_path)) {
+ protocol_stripped = strchr(base_path, ':');
+ if (protocol_stripped) {
+ protocol_stripped++;
+ }
+ }
+ p = protocol_stripped ?: base_path;
+
p1 = strrchr(base_path, '/');
#ifdef _WIN32
{
--
1.8.3.1
- [Qemu-block] [PULL 05/15] mirror: Drop permissions on s->target on completion, (continued)
- [Qemu-block] [PULL 05/15] mirror: Drop permissions on s->target on completion, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 04/15] nvme: Add support for Controller Memory Buffers, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 07/15] qemu-img: Fix documentation of convert, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 08/15] qemu-img: add support for --object with 'dd' command, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 06/15] qcow2: remove extra local_error variable, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 09/15] qemu-img: fix --image-opts usage with dd command, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 10/15] qemu-img: introduce --target-image-opts for 'convert' command, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 12/15] qemu-img: Fix leakage of options on error, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 11/15] qemu-img: copy *key-secret opts when opening newly created files, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 13/15] block: Tweak error message related to qemu-img amend, Kevin Wolf, 2017/05/29
- [Qemu-block] [PULL 14/15] block: Fix backing paths for filenames with colons,
Kevin Wolf <=
- [Qemu-block] [PULL 15/15] block/file-*: *_parse_filename() and colons, Kevin Wolf, 2017/05/29
- Re: [Qemu-block] [PULL 00/15] Block layer patches, Stefan Hajnoczi, 2017/05/30