Blame SOURCES/kvm-ssh-Don-t-crash-if-either-host-or-path-is-not-specif.patch

05bba0
From 566d5a879e639f0dd5beacf49e5fcb03691aac09 Mon Sep 17 00:00:00 2001
05bba0
From: Richard Jones <rjones@redhat.com>
05bba0
Date: Mon, 8 Jun 2015 11:57:00 +0200
05bba0
Subject: [PATCH 07/30] ssh: Don't crash if either host or path is not
05bba0
 specified.
05bba0
05bba0
Message-id: <1433764620-20506-7-git-send-email-rjones@redhat.com>
05bba0
Patchwork-id: 65481
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 6/6] ssh: Don't crash if either host or path is not specified.
05bba0
Bugzilla: 1226683
05bba0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
05bba0
From: "Richard W.M. Jones" <rjones@redhat.com>
05bba0
05bba0
$ ./qemu-img create -f qcow2 overlay \
05bba0
    -b 'json: { "file.driver":"ssh",
05bba0
                "file.host":"localhost",
05bba0
                "file.host_key_check":"no" }'
05bba0
qemu-img: qobject/qdict.c:193: qdict_get_obj: Assertion `obj != ((void *)0)' failed.
05bba0
Aborted
05bba0
05bba0
A similar crash also happens if the file.host field is omitted.
05bba0
05bba0
https://bugzilla.redhat.com/show_bug.cgi?id=1147343
05bba0
05bba0
Bug found and reported by Jun Li.
05bba0
05bba0
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
05bba0
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
05bba0
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
05bba0
Upstream-status: 18fe46d79a6de61cb2c379fb610d834ef658d84b
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 block/ssh.c | 10 ++++++++++
05bba0
 1 file changed, 10 insertions(+)
05bba0
05bba0
diff --git a/block/ssh.c b/block/ssh.c
05bba0
index 3b4d9e7..b00ff7f 100644
05bba0
--- a/block/ssh.c
05bba0
+++ b/block/ssh.c
05bba0
@@ -517,6 +517,11 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
05bba0
     const char *host, *user, *path, *host_key_check;
05bba0
     int port;
05bba0
 
05bba0
+    if (!qdict_haskey(options, "host")) {
05bba0
+        ret = -EINVAL;
05bba0
+        error_setg(errp, "No hostname was specified");
05bba0
+        goto err;
05bba0
+    }
05bba0
     host = qdict_get_str(options, "host");
05bba0
 
05bba0
     if (qdict_haskey(options, "port")) {
05bba0
@@ -525,6 +530,11 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
05bba0
         port = 22;
05bba0
     }
05bba0
 
05bba0
+    if (!qdict_haskey(options, "path")) {
05bba0
+        ret = -EINVAL;
05bba0
+        error_setg(errp, "No path was specified");
05bba0
+        goto err;
05bba0
+    }
05bba0
     path = qdict_get_str(options, "path");
05bba0
 
05bba0
     if (qdict_haskey(options, "user")) {
05bba0
-- 
05bba0
1.8.3.1
05bba0