diff options
author | 2010-04-12 10:51:01 +0200 | |
---|---|---|
committer | 2010-07-20 17:29:30 -0500 | |
commit | 3a753d89a68d3b2273a0c48cba5e47e039e501fe (patch) | |
tree | 7c92bba203578515a91d15d726bb85306f2e7bcb | |
parent | block: fix aio_flush segfaults for read-only protocols (e.g. curl) (diff) | |
download | qemu-kvm-3a753d89a68d3b2273a0c48cba5e47e039e501fe.tar.gz qemu-kvm-3a753d89a68d3b2273a0c48cba5e47e039e501fe.tar.bz2 qemu-kvm-3a753d89a68d3b2273a0c48cba5e47e039e501fe.zip |
qemu-sockets: avoid strlen of NULL pointer
If the user wants to create a chardev of type socket but forgets to give a
host= option, qemu_opt_get returns NULL. This NULL pointer is then fed into
strlen a few lines below without a check which results in a segfault.
This fixes it.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit e23a22e620e84f42bdbd473b82672654e7c8de73)
-rw-r--r-- | qemu-sockets.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/qemu-sockets.c b/qemu-sockets.c index a88b2a77f..993ce1215 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -130,7 +130,8 @@ int inet_listen_opts(QemuOpts *opts, int port_offset) ai.ai_family = PF_UNSPEC; ai.ai_socktype = SOCK_STREAM; - if (qemu_opt_get(opts, "port") == NULL) { + if ((qemu_opt_get(opts, "host") == NULL) || + (qemu_opt_get(opts, "port") == NULL)) { fprintf(stderr, "%s: host and/or port not specified\n", __FUNCTION__); return -1; } |