block/nfs: Check for NULL server part
authorMax Reitz <mreitz@redhat.com>
Mon, 5 May 2014 18:27:49 +0000 (20:27 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 9 May 2014 11:32:16 +0000 (13:32 +0200)
After the URL has been parsed make sure the server part is valid in
order to avoid a segmentation fault when calling nfs_mount().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/nfs.c

index 9fa831f..539bd95 100644 (file)
@@ -256,6 +256,10 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename,
         error_setg(errp, "Invalid URL specified");
         goto fail;
     }
+    if (!uri->server) {
+        error_setg(errp, "Invalid URL specified");
+        goto fail;
+    }
     strp = strrchr(uri->path, '/');
     if (strp == NULL) {
         error_setg(errp, "Invalid URL specified");