diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-05-08 16:51:48 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-05-10 10:32:12 +0200 |
commit | 947995c09ebd35a752837a5573985ba5a9942ec1 (patch) | |
tree | 9365a0a9f92be7685f09d2325ef70192dcd74545 /block.c | |
parent | f53f4da9c68941fe70a3ca9e3fc792c8acf69c0c (diff) | |
download | qemu-947995c09ebd35a752837a5573985ba5a9942ec1.zip qemu-947995c09ebd35a752837a5573985ba5a9942ec1.tar.gz qemu-947995c09ebd35a752837a5573985ba5a9942ec1.tar.bz2 |
block: protect path_has_protocol from filenames with colons
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 <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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) |