[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/23] ssh: Don't crash if either host or path is not
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 02/23] ssh: Don't crash if either host or path is not specified. |
Date: |
Sat, 4 Oct 2014 21:24:28 +0100 |
From: "Richard W.M. Jones" <address@hidden>
$ ./qemu-img create -f qcow2 overlay \
-b 'json: { "file.driver":"ssh",
"file.host":"localhost",
"file.host_key_check":"no" }'
qemu-img: qobject/qdict.c:193: qdict_get_obj: Assertion `obj != ((void *)0)'
failed.
Aborted
A similar crash also happens if the file.host field is omitted.
https://bugzilla.redhat.com/show_bug.cgi?id=1147343
Bug found and reported by Jun Li.
Signed-off-by: Richard W.M. Jones <address@hidden>
Reviewed-by: Gonglei <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/ssh.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/block/ssh.c b/block/ssh.c
index cf43bc0..f466cbf 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -517,6 +517,11 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
const char *host, *user, *path, *host_key_check;
int port;
+ if (!qdict_haskey(options, "host")) {
+ ret = -EINVAL;
+ error_setg(errp, "No hostname was specified");
+ goto err;
+ }
host = qdict_get_str(options, "host");
if (qdict_haskey(options, "port")) {
@@ -525,6 +530,11 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
port = 22;
}
+ if (!qdict_haskey(options, "path")) {
+ ret = -EINVAL;
+ error_setg(errp, "No path was specified");
+ goto err;
+ }
path = qdict_get_str(options, "path");
if (qdict_haskey(options, "user")) {
--
1.9.3
- [Qemu-devel] [PULL 00/23] Block patches, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 01/23] snapshot: fix referencing wrong variable in while loop in do_delvm, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 02/23] ssh: Don't crash if either host or path is not specified.,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 04/23] vmdk: Fix integer overflow in offset calculation, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 03/23] block: Drop superfluous conditionals around qemu_opts_del(), Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 05/23] Modify qemu_opt_rename to realize renaming all items in opts, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 06/23] make check-block: Use default cache modes, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 07/23] qemu-iotests: Fix supported cache modes for 052, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 08/23] blockdev: Orphaned drive search, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 09/23] blockdev: Allow overriding if_max_dev property, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 11/23] ide: Update ide_drive_get to be HBA agnostic, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 12/23] qtest/bios-tables: Correct Q35 command line, Stefan Hajnoczi, 2014/10/04
- [Qemu-devel] [PULL 10/23] pc/vl: Add units-per-default-bus property, Stefan Hajnoczi, 2014/10/04