qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 2/2] net: socket backend shows junk in "info network", fix
Date: Mon, 31 Oct 2011 17:11:38 +0100	[thread overview]
Message-ID: <1320077498-692-3-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1320077498-692-1-git-send-email-armbru@redhat.com>

net_socket_fd_init_dgram() prints uninitialized saddr into
nc->info_str.

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 net/socket.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index eb3e0d6..42bbae4 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -288,10 +288,15 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,
 
     nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name);
 
-    snprintf(nc->info_str, sizeof(nc->info_str),
-	    "socket: fd=%d (%s mcast=%s:%d)",
-	    fd, is_connected ? "cloned" : "",
-	    inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
+    if (is_connected) {
+        snprintf(nc->info_str, sizeof(nc->info_str),
+                 "socket: fd=%d (cloned mcast=%s:%d)",
+                 fd, inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
+    } else {
+        snprintf(nc->info_str, sizeof(nc->info_str),
+                 "socket: fd=%d",
+                 fd);
+    }
 
     s = DO_UPCAST(NetSocketState, nc, nc);
 
-- 
1.7.6.4

  parent reply	other threads:[~2011-10-31 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-31 16:11 [Qemu-devel] [PATCH 0/2] net: socket backend uses uninitialized variables Markus Armbruster
2011-10-31 16:11 ` [Qemu-devel] [PATCH 1/2] net: socket backend passes junk size to getsockname(), fix Markus Armbruster
2011-10-31 16:11 ` Markus Armbruster [this message]
2011-11-11  9:36 ` [Qemu-devel] [PATCH 0/2] net: socket backend uses uninitialized variables Markus Armbruster
2011-11-11 13:39   ` Anthony Liguori
2011-11-16  7:40     ` Markus Armbruster

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=1320077498-692-3-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=aliguori@us.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).