From: Jens Osterkamp Date: Mon, 12 Apr 2010 08:51:01 +0000 (+0200) Subject: qemu-sockets: avoid strlen of NULL pointer X-Git-Tag: TizenStudio_2.0_p2.3~4810 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8911bf077da42d21a4c179b4320bf328615bd7b2;p=sdk%2Femulator%2Fqemu.git 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 Signed-off-by: Aurelien Jarno --- diff --git a/qemu-sockets.c b/qemu-sockets.c index a7399aa..c526324 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; }