[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 60/61] block: Do not strcmp() with NULL uri->scheme
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 60/61] block: Do not strcmp() with NULL uri->scheme |
Date: |
Fri, 23 Jun 2017 18:21:58 +0200 |
From: Max Reitz <address@hidden>
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: address@hidden
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/nbd.c | 6 +++---
block/nfs.c | 2 +-
block/sheepdog.c | 6 +++---
block/ssh.c | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index e946ea9..d529305 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -64,11 +64,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 6b8b5b6..c3c5de0 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -82,7 +82,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 a87ee5f..08d7b11 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1046,11 +1046,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 bac3453..5296441 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -204,7 +204,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;
}
--
1.8.3.1
- [Qemu-block] [PULL 48/61] qed: Remove recursion in qed_aio_next_io(), (continued)
- [Qemu-block] [PULL 48/61] qed: Remove recursion in qed_aio_next_io(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 49/61] qed: Implement .bdrv_co_readv/writev, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 53/61] qed: Add coroutine_fn to I/O path functions, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 52/61] qed: Use a coroutine for need_check_timer, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 54/61] qed: Use bdrv_co_* for coroutine_fns, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 55/61] block: Remove bdrv_aio_readv/writev/flush(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 57/61] fix: avoid an infinite loop or a dangling pointer problem in img_commit, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 58/61] blkdebug: Catch bs->exact_filename overflow, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 61/61] qemu-img: don't shadow opts variable in img_dd(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 59/61] blkverify: Catch bs->exact_filename overflow, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 60/61] block: Do not strcmp() with NULL uri->scheme,
Kevin Wolf <=
- [Qemu-block] [PULL 56/61] block: change variable names in BlockDriverState, Kevin Wolf, 2017/06/23
- Re: [Qemu-block] [Qemu-devel] [PULL 00/61] Block layer patches, Peter Maydell, 2017/06/26