All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: netdev@vger.kernel.org
Subject: return 0 when MSG_OOB in ping_recvmsg
Date: Tue, 21 Feb 2012 17:50:59 -0500	[thread overview]
Message-ID: <20120221225058.GA15387@redhat.com> (raw)

If a packet causes the 'if (flags & MSG_OOB)' test this function does first
thing is true, it returns an uninitialised variable from the stack.

There may be a better return code for this failure, but returning
'0 bytes copied' seems better than just returning garbage.

Signed-off-by: Dave Jones <davej@redhat.com>

diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index aea5a19..0823562 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -626,7 +626,7 @@ static int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 	struct inet_sock *isk = inet_sk(sk);
 	struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
 	struct sk_buff *skb;
-	int copied, err;
+	int copied, err = 0;
 
 	pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num);
 

             reply	other threads:[~2012-02-21 22:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21 22:50 Dave Jones [this message]
2012-02-21 22:59 ` return 0 when MSG_OOB in ping_recvmsg David Miller

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=20120221225058.GA15387@redhat.com \
    --to=davej@redhat.com \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.