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