[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 64/79] block: Do not strcmp() with NULL uri->scheme
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 64/79] block: Do not strcmp() with NULL uri->scheme |
Date: |
Mon, 28 Aug 2017 19:14:39 -0500 |
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>
(cherry picked from commit f69165a8feca055cf4a37d13ab0fc5beec3cb372)
Signed-off-by: Michael Roth <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 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;
}
--
2.7.4
- [Qemu-stable] [PATCH 56/79] target/xtensa: handle unknown registers in gdbstub, (continued)
- [Qemu-stable] [PATCH 56/79] target/xtensa: handle unknown registers in gdbstub, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 67/79] spapr: fix migration to pseries machine < 2.8, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 66/79] hid: Reset kbd modifiers on reset, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 57/79] commit: Fix use after free in completion, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 59/79] nbd: Fix regression on resiliency to port scan, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 68/79] virtio-scsi: finalize IOMMU support, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 73/79] input: Decrement queue count on kbd delay, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 71/79] virtio-net: fix offload ctrl endian, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 74/79] qemu-iotests: Test automatic commit job cancel on hot unplug, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 76/79] cpu: don't allow negative core id, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 64/79] block: Do not strcmp() with NULL uri->scheme,
Michael Roth <=
- [Qemu-stable] [PATCH 69/79] commit: Add NULL check for overlay_bs, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 70/79] spapr: fix memory leak in spapr_core_pre_plug(), Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 07/79] iotests/051: Add test for empty filename, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 06/79] block: An empty filename counts as no filename, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 72/79] input: limit kbd queue depth, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 75/79] block: Skip implicit nodes in query-block/blockstats, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 78/79] block/nfs: fix mutex assertion in nfs_file_close(), Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 77/79] hw/i386: allow SHPC for Q35 machine, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 08/79] migration: setup bi-directional I/O channel for exec: protocol, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 79/79] 9pfs: local: fix fchmodat_nofollow() limitations, Michael Roth, 2017/08/28