diff options
author | 2011-01-22 13:07:26 +0000 | |
---|---|---|
committer | 2011-02-20 18:26:41 +0100 | |
commit | 8d610b6ba2b36bbe0159362556455b61c6566526 (patch) | |
tree | 1c22601402b026b55a93a0ea335749457f68d609 | |
parent | Update version for 0.14.0 (diff) | |
download | qemu-kvm-8d610b6ba2b36bbe0159362556455b61c6566526.tar.gz qemu-kvm-8d610b6ba2b36bbe0159362556455b61c6566526.tar.bz2 qemu-kvm-8d610b6ba2b36bbe0159362556455b61c6566526.zip |
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>
-rw-r--r-- | qemu-char.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/qemu-char.c b/qemu-char.c index ee4f4cab2..bd4e944e1 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; |