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 1/2] net: socket backend passes junk size to getsockname(), fix
Date: Mon, 31 Oct 2011 17:11:37 +0100	[thread overview]
Message-ID: <1320077498-692-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1320077498-692-1-git-send-email-armbru@redhat.com>

net_socket_fd_init_dgram() passes an uninitialized address length to
getsockname().  I guess this happens to work as long as the junk value
is at least sizeof(sockaddr_in).

Spotted by Coverity.

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

diff --git a/net/socket.c b/net/socket.c
index e9ef128..eb3e0d6 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -260,6 +260,7 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,
      */
 
     if (is_connected) {
+        saddr_len = sizeof(saddr);
 	if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {
 	    /* must be bound */
 	    if (saddr.sin_addr.s_addr==0) {
-- 
1.7.6.4

  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 ` Markus Armbruster [this message]
2011-10-31 16:11 ` [Qemu-devel] [PATCH 2/2] net: socket backend shows junk in "info network", fix Markus Armbruster
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-2-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).