From: Jens Osterkamp <jens@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2] qemu-kvm: avoid strlen of NULL pointer
Date: Mon, 12 Apr 2010 10:51:01 +0200 [thread overview]
Message-ID: <201004121051.02057.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, 2 insertions(+), 1 deletions(-)
diff --git a/qemu-sockets.c b/qemu-sockets.c
index 23c3def..87a79e5 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, "port") == NULL) ||
+ (qemu_opt_get(opts, "host") == NULL)) {
fprintf(stderr, "%s: host and/or port not specified\n", __FUNCTION__);
return -1;
}
--
1.5.6.3
next reply other threads:[~2010-04-12 8:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-12 8:51 Jens Osterkamp [this message]
2010-05-18 17:48 ` [Qemu-devel] [PATCH v2] 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=201004121051.02057.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).