aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2017-06-13 22:57:26 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2017-08-24 16:58:11 -0500
commit438cd1e6aacbb0755ab8ec8a03d34998c3ab0ea3 (patch)
tree08875e4bf9684eba5db89bb35bfb70047514faad /block
parent40ed5cdf724598f42907dd5a6b33f4f93dce398a (diff)
downloadqemu-438cd1e6aacbb0755ab8ec8a03d34998c3ab0ea3.zip
qemu-438cd1e6aacbb0755ab8ec8a03d34998c3ab0ea3.tar.gz
qemu-438cd1e6aacbb0755ab8ec8a03d34998c3ab0ea3.tar.bz2
block: Do not strcmp() with NULL uri->scheme
uri_parse(...)->scheme may be NULL. In fact, probably every field may be NULL, and the callers do test this for all of the other fields but not for scheme (except for block/gluster.c; block/vxhs.c does not access that field at all). We can easily fix this by using g_strcmp0() instead of strcmp(). Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz <mreitz@redhat.com> Message-id: 20170613205726.13544-1-mreitz@redhat.com Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> (cherry picked from commit f69165a8feca055cf4a37d13ab0fc5beec3cb372) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'block')
-rw-r--r--block/nbd.c6
-rw-r--r--block/nfs.c2
-rw-r--r--block/sheepdog.c6
-rw-r--r--block/ssh.c2
4 files changed, 8 insertions, 8 deletions
diff --git a/block/nbd.c b/block/nbd.c
index b3545f5..9a54edf 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -65,11 +65,11 @@ static int nbd_parse_uri(const char *filename, QDict *options)
}
/* transport */
- if (!strcmp(uri->scheme, "nbd")) {
+ if (!g_strcmp0(uri->scheme, "nbd")) {
is_unix = false;
- } else if (!strcmp(uri->scheme, "nbd+tcp")) {
+ } else if (!g_strcmp0(uri->scheme, "nbd+tcp")) {
is_unix = false;
- } else if (!strcmp(uri->scheme, "nbd+unix")) {
+ } else if (!g_strcmp0(uri->scheme, "nbd+unix")) {
is_unix = true;
} else {
ret = -EINVAL;
diff --git a/block/nfs.c b/block/nfs.c
index bfeebc1..344186f 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -83,7 +83,7 @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp)
error_setg(errp, "Invalid URI specified");
goto out;
}
- if (strcmp(uri->scheme, "nfs") != 0) {
+ if (g_strcmp0(uri->scheme, "nfs") != 0) {
error_setg(errp, "URI scheme must be 'nfs'");
goto out;
}
diff --git a/block/sheepdog.c b/block/sheepdog.c
index fb9203e..2d8d8c8 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1052,11 +1052,11 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
}
/* transport */
- if (!strcmp(uri->scheme, "sheepdog")) {
+ if (!g_strcmp0(uri->scheme, "sheepdog")) {
is_unix = false;
- } else if (!strcmp(uri->scheme, "sheepdog+tcp")) {
+ } else if (!g_strcmp0(uri->scheme, "sheepdog+tcp")) {
is_unix = false;
- } else if (!strcmp(uri->scheme, "sheepdog+unix")) {
+ } else if (!g_strcmp0(uri->scheme, "sheepdog+unix")) {
is_unix = true;
} else {
error_setg(&err, "URI scheme must be 'sheepdog', 'sheepdog+tcp',"
diff --git a/block/ssh.c b/block/ssh.c
index 34a2f79..139b05d 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -205,7 +205,7 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
return -EINVAL;
}
- if (strcmp(uri->scheme, "ssh") != 0) {
+ if (g_strcmp0(uri->scheme, "ssh") != 0) {
error_setg(errp, "URI scheme must be 'ssh'");
goto err;
}