summaryrefslogtreecommitdiff
path: root/qemu-sockets.c
diff options
context:
space:
mode:
authorJens Osterkamp <jens@linux.vnet.ibm.com>2010-04-12 10:51:01 +0200
committerAurelien Jarno <aurelien@aurel32.net>2010-05-18 19:49:16 +0200
commite23a22e620e84f42bdbd473b82672654e7c8de73 (patch)
treeddc9cebadadc2810e1228759ab02ea575aa4d9ab /qemu-sockets.c
parent81bbe906c89b6b7af58a1eeb96ec5a0bfdc3386f (diff)
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>
Diffstat (limited to 'qemu-sockets.c')
-rw-r--r--qemu-sockets.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/qemu-sockets.c b/qemu-sockets.c
index a7399aa945..c526324998 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;
}