From: Anderson Lizardo <anderson.lizardo@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Anderson Lizardo <anderson.lizardo@openbossa.org>
Subject: [PATCH BlueZ] Fix memory corruption when decoding Read Response PDU
Date: Wed, 28 Sep 2011 15:01:32 -0400 [thread overview]
Message-ID: <1317236492-13064-1-git-send-email-anderson.lizardo@openbossa.org> (raw)
A bogus (or hostile) Proximity Reporter device may send a TX Power value
bigger than the buffer used. Therefore, create a temporary buffer with
the maximum size, and check for the length before using the value.
Note that all other current users of the dec_read_resp() already do
this. Another option would be to change dec_read_resp() to accept a
buffer length, but this would break external code, so it is avoided for
now.
---
proximity/monitor.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/proximity/monitor.c b/proximity/monitor.c
index 0ce48db..884e66d 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -186,7 +186,7 @@ static int write_alert_level(struct monitor *monitor)
static void tx_power_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data)
{
- uint8_t value;
+ uint8_t value[ATT_MAX_MTU];
int vlen;
if (status != 0) {
@@ -194,12 +194,17 @@ static void tx_power_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
return;
}
- if (!dec_read_resp(pdu, plen, &value, &vlen)) {
+ if (!dec_read_resp(pdu, plen, value, &vlen)) {
DBG("Protocol error");
return;
}
- DBG("Tx Power Level: %02x", (int8_t) value);
+ if (vlen != 1) {
+ DBG("Invalid length for TX Power value: %d", vlen);
+ return;
+ }
+
+ DBG("Tx Power Level: %02x", (int8_t) value[0]);
}
static void tx_power_handle_cb(GSList *characteristics, guint8 status,
--
1.7.0.4
next reply other threads:[~2011-09-28 19:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-28 19:01 Anderson Lizardo [this message]
2011-10-03 8:51 ` [PATCH BlueZ] Fix memory corruption when decoding Read Response PDU Johan Hedberg
2011-10-03 22:59 ` Anderson Lizardo
2011-10-05 10:32 ` Johan Hedberg
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=1317236492-13064-1-git-send-email-anderson.lizardo@openbossa.org \
--to=anderson.lizardo@openbossa.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