From: Jens Osterkamp <jens@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] qemu-kvm: avoid strlen of NULL pointer
Date: Wed, 3 Mar 2010 15:32:43 +0100 [thread overview]
Message-ID: <201003031532.43257.jens@linux.vnet.ibm.com> (raw)
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>
---
qemu-sockets.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/qemu-sockets.c b/qemu-sockets.c
index 23c3def..a191304 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -137,6 +137,9 @@ int inet_listen_opts(QemuOpts *opts, int port_offset)
pstrcpy(port, sizeof(port), qemu_opt_get(opts, "port"));
addr = qemu_opt_get(opts, "host");
+ if (!addr)
+ return -1;
+
to = qemu_opt_get_number(opts, "to", 0);
if (qemu_opt_get_bool(opts, "ipv4", 0))
ai.ai_family = PF_INET;
--
1.5.6.3
--
Best regards,
Jens Osterkamp
--------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
next reply other threads:[~2010-03-03 14:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-03 14:32 Jens Osterkamp [this message]
2010-03-27 12:33 ` [Qemu-devel] [PATCH] qemu-kvm: avoid strlen of NULL pointer Aurelien Jarno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201003031532.43257.jens@linux.vnet.ibm.com \
--to=jens@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).