aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2011-01-22 13:07:26 +0000
committerAurelien Jarno <aurelien@aurel32.net>2011-02-20 18:26:28 +0100
commit1bbd185fa826a2da7c6089b968f9f7d08438c2c8 (patch)
treeb300a4248851f9a5edeb0c9d19f120def572a0d8 /qemu-char.c
parent9f953ca0b8ae71f4ea8112a3aac36454a2c4b907 (diff)
qemu-char: Check for missing backend name
Check if the backend option is missing before searching the backend table. This fixes a NULL pointer dereference when QEMU is invoked with the following invalid command-line: $ qemu -chardev id=foo,path=/tmp/socket Previously QEMU would segfault, now it produces this error message: chardev: "foo" missing backend Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/qemu-char.c b/qemu-char.c
index ee4f4cab2d..bd4e944e1d 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2506,6 +2506,11 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
return NULL;
}
+ if (qemu_opt_get(opts, "backend") == NULL) {
+ fprintf(stderr, "chardev: \"%s\" missing backend\n",
+ qemu_opts_id(opts));
+ return NULL;
+ }
for (i = 0; i < ARRAY_SIZE(backend_table); i++) {
if (strcmp(backend_table[i].name, qemu_opt_get(opts, "backend")) == 0)
break;