[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] net: socket backend shows junk in "info network
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH 2/2] net: socket backend shows junk in "info network", fix |
Date: |
Mon, 31 Oct 2011 17:11:38 +0100 |
net_socket_fd_init_dgram() prints uninitialized saddr into
nc->info_str.
Spotted by Coverity.
Signed-off-by: Markus Armbruster <address@hidden>
---
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