[PATCH 5/6] Fix access to an invalid memory sector if time stamp is not supported

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 thermometer/thermometer.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 4faf900..e37254c 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -1073,12 +1073,18 @@ static void proc_measurement(struct thermometer *t, const uint8_t *pdu,
 		m.suptime = FALSE;
 
 	if (flags & TEMP_TYPE) {
-		if (len < 16) {
+		uint8_t index;
+
+		if (m.suptime && len >= 16)
+			index = 15;
+		else if (!m.suptime && len >= 9)
+			index = 9;
+		else {
 			DBG("Can't get temperature type");
 			return;
 		}
 
-		type = temptype2str(pdu[15]);
+		type = temptype2str(pdu[index]);
 	} else if (t->has_type)
 		type = temptype2str(t->type);
 	else {
-- 
1.7.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux