aboutsummaryrefslogtreecommitdiffstats
path: root/thermometer/thermometer.c
diff options
context:
space:
mode:
authorSantiago Carot-Nemesio <sancane@gmail.com>2011-12-09 19:19:02 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2011-12-15 13:24:21 +0200
commit726dc13a33ef1a73854521f9306536904b48eb93 (patch)
treee7d855f438961668f59a4d3be874f1cecbd712be /thermometer/thermometer.c
parent3ff4427f399f13e126185e9e429752a2fc524a9b (diff)
downloadbluez-726dc13a33ef1a73854521f9306536904b48eb93.tar.gz
bluez-726dc13a33ef1a73854521f9306536904b48eb93.tar.xz
bluez-726dc13a33ef1a73854521f9306536904b48eb93.zip
thermometer: Fix possible NULL pointer deference
This patch checks 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.
Diffstat (limited to 'thermometer/thermometer.c')
-rw-r--r--thermometer/thermometer.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index bc05edc4..e78d250e 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");