All of lore.kernel.org
 help / color / mirror / Atom feed
From: Santiago Carot-Nemesio <sancane@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Santiago Carot-Nemesio <sancane@gmail.com>
Subject: [PATCH 4/6] thermometer.c: Fix possible null pointer deference
Date: Fri,  9 Dec 2011 19:19:02 +0100	[thread overview]
Message-ID: <1323454744-14589-5-git-send-email-sancane@gmail.com> (raw)
In-Reply-To: <1323454744-14589-4-git-send-email-sancane@gmail.com>

This patch check the GATT server is connected before doing any
GATT transaction. If it isn't, we abort the operation to avoid the
NULL pointer deference problem.
---
 thermometer/thermometer.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index da793a6..ad1569b 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -598,6 +598,9 @@ static DBusMessage *write_attr_interval(struct thermometer *t, DBusMessage *msg,
 	struct characteristic *ch;
 	guint8 atval[2];
 
+	if (t->attrib == NULL)
+		return btd_error_not_connected(msg);
+
 	ch = get_characteristic(t, MEASUREMENT_INTERVAL_UUID);
 	if (ch == NULL)
 		return btd_error_not_available(msg);
@@ -671,6 +674,9 @@ static void enable_final_measurement(struct thermometer *t)
 	uint8_t atval[2];
 	gchar *msg;
 
+	if (t->attrib == NULL)
+		return;
+
 	ch = get_characteristic(t, TEMPERATURE_MEASUREMENT_UUID);
 	if (ch == NULL) {
 		DBG("Temperature measurement characteristic not found");
@@ -698,6 +704,9 @@ static void enable_intermediate_measurement(struct thermometer *t)
 	uint8_t atval[2];
 	gchar *msg;
 
+	if (t->attrib == NULL)
+		return;
+
 	ch = get_characteristic(t, INTERMEDIATE_TEMPERATURE_UUID);
 	if (ch == NULL) {
 		DBG("Intermediate measurement characteristic not found");
@@ -725,6 +734,9 @@ static void disable_final_measurement(struct thermometer *t)
 	uint8_t atval[2];
 	gchar *msg;
 
+	if (t->attrib == NULL)
+		return;
+
 	ch = get_characteristic(t, TEMPERATURE_MEASUREMENT_UUID);
 	if (ch == NULL) {
 		DBG("Temperature measurement characteristic not found");
@@ -752,6 +764,9 @@ static void disable_intermediate_measurement(struct thermometer *t)
 	uint8_t atval[2];
 	gchar *msg;
 
+	if (t->attrib == NULL)
+		return;
+
 	ch = get_characteristic(t, INTERMEDIATE_TEMPERATURE_UUID);
 	if (ch == NULL) {
 		DBG("Intermediate measurement characteristic not found");
-- 
1.7.8


  reply	other threads:[~2011-12-09 18:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09 18:18 Health Thermometer Profile patches Santiago Carot-Nemesio
2011-12-09 18:18 ` [PATCH 1/6] thermometer.c: Implement SetProperty D-Bus method Santiago Carot-Nemesio
2011-12-09 18:19   ` [PATCH 2/6] thermometer.c: Confiure C.C.C descriptor during the thermometer configuration Santiago Carot-Nemesio
2011-12-09 18:19     ` [PATCH 3/6] thermometer.c: Process measurement interval indications Santiago Carot-Nemesio
2011-12-09 18:19       ` Santiago Carot-Nemesio [this message]
2011-12-09 18:19         ` [PATCH 5/6] thermometer.c: Fix bad read operation when time stamp is not provided Santiago Carot-Nemesio
2011-12-09 18:19           ` [PATCH 6/6] thermometer.c: Use system types instead of GLIB ones Santiago Carot-Nemesio
2011-12-15 11:29 ` Health Thermometer Profile patches 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=1323454744-14589-5-git-send-email-sancane@gmail.com \
    --to=sancane@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 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.