[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1.1 08/22] block: protect path_has_protocol from fil
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 1.1 08/22] block: protect path_has_protocol from filenames with colons |
Date: |
Tue, 8 May 2012 16:51:48 +0200 |
path_has_protocol will erroneously return "true" if the colon is part
of a filename. These names are common with stable device names produced
by udev. We cannot fully protect against this in case the filename
does not have a path component (e.g. if the current directory is
/dev/disk/by-path), but in the common case there will be a slash before
and path_has_protocol can easily detect that and return false.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 0fb188f..8eeb519 100644
--- a/block.c
+++ b/block.c
@@ -198,14 +198,19 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs,
/* check if the path starts with "<protocol>:" */
static int path_has_protocol(const char *path)
{
+ const char *p;
+
#ifdef _WIN32
if (is_windows_drive(path) ||
is_windows_drive_prefix(path)) {
return 0;
}
+ p = path + strcspn(path, ":/\\");
+#else
+ p = path + strcspn(path, ":/");
#endif
- return strchr(path, ':') != NULL;
+ return *p == ':';
}
int path_is_absolute(const char *path)
--
1.7.10.1
- [Qemu-devel] [PATCH 1.1 01/22] block: fix snapshot on QED, (continued)
- [Qemu-devel] [PATCH 1.1 01/22] block: fix snapshot on QED, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 03/22] block: do not reuse the backing file across bdrv_close/bdrv_open, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 05/22] block: add block_job_sleep_ns, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 04/22] block: fully delete bs->file when closing, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 06/22] block: wait for job callback in block_job_cancel_sync, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 07/22] block: simplify path_is_absolute, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 09/22] block: move field reset from bdrv_open_common to bdrv_close, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 08/22] block: protect path_has_protocol from filenames with colons,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 1.1 10/22] qemu-img: make "info" backing file output correct and easier to use, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 13/22] stream: fix sectors not allocated test, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 16/22] stream: fix HMP block_job_set_speed, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 14/22] stream: add testcase for partial streaming, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 15/22] stream: pass new base image format to bdrv_change_backing_file, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 17/22] stream: fix ratelimiting corner case, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 18/22] stream: do not copy unallocated sectors from the base, Paolo Bonzini, 2012/05/08
- [Qemu-devel] [PATCH 1.1 20/22] stream: tweak usage of bdrv_co_is_allocated, Paolo Bonzini, 2012/05/08