]> Git Repo - qemu.git/commitdiff
block: Do not strcmp() with NULL uri->scheme
authorMax Reitz <[email protected]>
Tue, 13 Jun 2017 20:57:26 +0000 (22:57 +0200)
committerMax Reitz <[email protected]>
Mon, 26 Jun 2017 12:54:46 +0000 (14:54 +0200)
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: [email protected]
Signed-off-by: Max Reitz <[email protected]>
Message-id: 20170613205726[email protected]
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
block/nbd.c
block/nfs.c
block/sheepdog.c
block/ssh.c

index e946ea944dcb5ad3dccd00e92ebe429aea3c5581..d52930533004fc9cc4fb7914e7ec0ad78ef5dae3 100644 (file)
@@ -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;
index 6b8b5b653d6c03b50380c4cca15afe954867853e..c3c5de011376d1f9a25d00657087a019ba83af9c 100644 (file)
@@ -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;
     }
index a87ee5facd3aef378d825b8498128fcd85033c17..08d7b11e9d34460e13496d6e70922e995fe9f800 100644 (file)
@@ -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',"
index bac3453c3e9d7808618f5878007c9b4aa10b5bd6..52964416da23646b019639c4a2ffa66f9524c7f6 100644 (file)
@@ -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;
     }
This page took 0.038335 seconds and 4 git commands to generate.