public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
Cc: Gustavo Padovan <gustavo@padovan.org>,
	Andre Guedes <andre.guedes@openbossa.org>,
	"linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>
Subject: Re: [RFC] Bluetooth: Fix compile warning in l2cap_core.c
Date: Wed, 6 Jun 2012 09:58:32 +0200	[thread overview]
Message-ID: <201206060958.32857.szymon.janc@tieto.com> (raw)
In-Reply-To: <20120606073320.GA2754@aemeltch-MOBL1>

Hi,

(as plain text this time...)

> > > I'm not sure this is a false positive. If remote device misbehaves and
> > > sends bogus L2CAP_CONF_RFC with wrong length (as Szymon said) we go to
> > > "done" label and 'rfc' is used uninitialized.
> 
> what is not OK is that double conversion.

Maybe sth like that? This function is expected to extract only conf_rfc anyway..

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index f9bffe3..42b8af6 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3273,12 +3273,14 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
        while (len >= L2CAP_CONF_OPT_SIZE) {
                len -= l2cap_get_conf_opt(&rsp, &type, &olen, &val);
 
-               switch (type) {
-               case L2CAP_CONF_RFC:
-                       if (olen == sizeof(rfc))
-                               memcpy(&rfc, (void *)val, olen);
-                       goto done;
-               }
+               if (type != L2CAP_CONF_RFC)
+                       continue;
+
+               if (olen != sizeof(rfc))
+                       break;
+
+               memcpy(&rfc, (void *)val, olen);
+               goto done;
        }

        /* Use sane default values in case a misbehaving remote device

-- 
BR
Szymon Janc

      reply	other threads:[~2012-06-06  7:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-31 23:39 [RFC] Bluetooth: Fix compile warning in l2cap_core.c Andre Guedes
2012-06-01  7:03 ` Andrei Emeltchenko
2012-06-01 23:09 ` Gustavo Padovan
2012-06-04  7:17   ` Szymon Janc
2012-06-05 19:01     ` Andre Guedes
2012-06-06  4:38       ` Gustavo Padovan
2012-06-06  7:33         ` Andrei Emeltchenko
2012-06-06  7:58           ` Szymon Janc [this message]

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=201206060958.32857.szymon.janc@tieto.com \
    --to=szymon.janc@tieto.com \
    --cc=andre.guedes@openbossa.org \
    --cc=andrei.emeltchenko.news@gmail.com \
    --cc=gustavo@padovan.org \
    --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