qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] qemu-kvm: avoid strlen of NULL pointer
@ 2010-04-12  8:51 Jens Osterkamp
  2010-05-18 17:48 ` Aurelien Jarno
  0 siblings, 1 reply; 2+ messages in thread
From: Jens Osterkamp @ 2010-04-12  8:51 UTC (permalink / raw)
  To: qemu-devel


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH v2] qemu-kvm: avoid strlen of NULL pointer
  2010-04-12  8:51 [Qemu-devel] [PATCH v2] qemu-kvm: avoid strlen of NULL pointer Jens Osterkamp
@ 2010-05-18 17:48 ` Aurelien Jarno
  0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2010-05-18 17:48 UTC (permalink / raw)
  To: Jens Osterkamp; +Cc: qemu-devel

On Mon, Apr 12, 2010 at 10:51:01AM +0200, Jens Osterkamp wrote:
> 
> 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>

Thanks, applied.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-18 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-12  8:51 [Qemu-devel] [PATCH v2] qemu-kvm: avoid strlen of NULL pointer Jens Osterkamp
2010-05-18 17:48 ` Aurelien Jarno

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).