Linux bluetooth development
 help / color / mirror / Atom feed
From: johan.hedberg@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 3/4] Bluetooth: Refuse peer RFCOMM address reading when not connected
Date: Tue, 28 Jan 2014 15:16:50 -0800	[thread overview]
Message-ID: <1390951011-30576-3-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1390951011-30576-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

When we're not connected the peer address information is undefined. This
patch fixes the remote address getting to return a proper error in case
the sate is anything else than BT_CONNECTED.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/rfcomm/sock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index fb8158af1f39..00573fb79030 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -528,6 +528,9 @@ static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int *
 
 	BT_DBG("sock %p, sk %p", sock, sk);
 
+	if (peer && sk->sk_state != BT_CONNECTED)
+		return -ENOTCONN;
+
 	memset(sa, 0, sizeof(*sa));
 	sa->rc_family  = AF_BLUETOOTH;
 	sa->rc_channel = rfcomm_pi(sk)->channel;
-- 
1.8.5.3


  parent reply	other threads:[~2014-01-28 23:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 23:16 [PATCH 1/4] Bluetooth: Free up l2cap_chan->sport when initiating a connection johan.hedberg
2014-01-28 23:16 ` [PATCH 2/4] Bluetooth: Refuse peer L2CAP address reading when not connected johan.hedberg
2014-01-28 23:29   ` Marcel Holtmann
2014-01-28 23:16 ` johan.hedberg [this message]
2014-01-28 23:31   ` [PATCH 3/4] Bluetooth: Refuse peer RFCOMM " Marcel Holtmann
2014-01-28 23:16 ` [PATCH 4/4] Bluetooth: Always use l2cap_chan->psm for returning PSM to user space johan.hedberg
2014-01-28 23:33   ` Marcel Holtmann
2014-01-28 23:28 ` [PATCH 1/4] Bluetooth: Free up l2cap_chan->sport when initiating a connection Marcel Holtmann

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=1390951011-30576-3-git-send-email-johan.hedberg@gmail.com \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox