linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix problem with invalid read from array
@ 2010-10-06 12:52 Lukasz Pawlik
  2010-10-06 13:32 ` Johan Hedberg
  0 siblings, 1 reply; 5+ messages in thread
From: Lukasz Pawlik @ 2010-10-06 12:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Pawlik

This patch fix problem with reading data from out of the array range in
function used to create EIR response.
---
 src/adapter.c      |    2 +-
 src/sdpd-service.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 73ea6e4..bf32e19 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -205,7 +205,7 @@ static void dev_info_free(struct remote_dev_info *dev)
 
 static void update_ext_inquiry_response(struct btd_adapter *adapter)
 {
-	uint8_t data[240];
+	uint8_t data[242];
 	struct hci_dev *dev = &adapter->dev;
 	int ret;
 
diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index 26ab9a5..67dd9af 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -204,7 +204,7 @@ static void eir_generate_uuid128(sdp_list_t *list,
 		for (i = 0; i < index; i++) {
 			for (k = 0; k < SIZEOF_UUID128; k++) {
 				if (uuid128[i * SIZEOF_UUID128 + k] !=
-					uuid128_data[SIZEOF_UUID128 - k])
+					uuid128_data[SIZEOF_UUID128 - 1 - k])
 					break;
 			}
 			if (k == SIZEOF_UUID128)
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix problem with invalid read from array
  2010-10-06 12:52 [PATCH] Fix problem with invalid read from array Lukasz Pawlik
@ 2010-10-06 13:32 ` Johan Hedberg
  2010-10-06 15:33   ` Lukasz Pawlik
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hedberg @ 2010-10-06 13:32 UTC (permalink / raw)
  To: Lukasz Pawlik; +Cc: linux-bluetooth

Hi Lukasz,

On Wed, Oct 06, 2010, Lukasz Pawlik wrote:
> This patch fix problem with reading data from out of the array range in
> function used to create EIR response.

You'll need to explain in more detail exactly what was wrong with the
old code and how your patch fixes it (and why it is the correct fix).

> -	uint8_t data[240];
> +	uint8_t data[242];

Why 242? The core spec defines the EIR data as a 240 byte field.

> -					uuid128_data[SIZEOF_UUID128 - k])
> +					uuid128_data[SIZEOF_UUID128 - 1 - k])

This change looks fine (the index of the last byte is sizeof(uuid128) - 1).

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix problem with invalid read from array
  2010-10-06 13:32 ` Johan Hedberg
@ 2010-10-06 15:33   ` Lukasz Pawlik
  2010-10-08  8:35     ` Lukasz Pawlik
  0 siblings, 1 reply; 5+ messages in thread
From: Lukasz Pawlik @ 2010-10-06 15:33 UTC (permalink / raw)
  To: Lukasz Pawlik, linux-bluetooth

Hi,

Sorry. My bad. It was never my intention to change src/adapter.c. I've
prepared two patches with the same name and of course send the wrong
one. Problem with invalid read fix change made in src/sdpd-service.c
file.

Lukasz

2010/10/6 Johan Hedberg <johan.hedberg@gmail.com>:
> Hi Lukasz,
>
> On Wed, Oct 06, 2010, Lukasz Pawlik wrote:
>> This patch fix problem with reading data from out of the array range in
>> function used to create EIR response.
>
> You'll need to explain in more detail exactly what was wrong with the
> old code and how your patch fixes it (and why it is the correct fix).
>
>> -     uint8_t data[240];
>> +     uint8_t data[242];
>
> Why 242? The core spec defines the EIR data as a 240 byte field.
>
>> -                                     uuid128_data[SIZEOF_UUID128 - k])
>> +                                     uuid128_data[SIZEOF_UUID128 - 1 - k])
>
> This change looks fine (the index of the last byte is sizeof(uuid128) - 1).
>
> Johan
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix problem with invalid read from array
  2010-10-06 15:33   ` Lukasz Pawlik
@ 2010-10-08  8:35     ` Lukasz Pawlik
  2010-10-09 15:12       ` Johan Hedberg
  0 siblings, 1 reply; 5+ messages in thread
From: Lukasz Pawlik @ 2010-10-08  8:35 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]

Attaching patch without change in src/adapter.c file.

Lukasz Pawlik

2010/10/6 Lukasz Pawlik <lucas.pawlik@gmail.com>:
> Hi,
>
> Sorry. My bad. It was never my intention to change src/adapter.c. I've
> prepared two patches with the same name and of course send the wrong
> one. Problem with invalid read fix change made in src/sdpd-service.c
> file.
>
> Lukasz
>
> 2010/10/6 Johan Hedberg <johan.hedberg@gmail.com>:
>> Hi Lukasz,
>>
>> On Wed, Oct 06, 2010, Lukasz Pawlik wrote:
>>> This patch fix problem with reading data from out of the array range in
>>> function used to create EIR response.
>>
>> You'll need to explain in more detail exactly what was wrong with the
>> old code and how your patch fixes it (and why it is the correct fix).
>>
>>> -     uint8_t data[240];
>>> +     uint8_t data[242];
>>
>> Why 242? The core spec defines the EIR data as a 240 byte field.
>>
>>> -                                     uuid128_data[SIZEOF_UUID128 - k])
>>> +                                     uuid128_data[SIZEOF_UUID128 - 1 - k])
>>
>> This change looks fine (the index of the last byte is sizeof(uuid128) - 1).
>>
>> Johan
>>
>

[-- Attachment #2: 0001-Fix-problem-with-invalid-read-from-array.patch --]
[-- Type: text/x-patch, Size: 876 bytes --]

From 5e6ca8e9dff0ced5aacc1cbfa12318680ade957a Mon Sep 17 00:00:00 2001
From: Lukasz Pawlik <lucas.pawlik@gmail.com>
Date: Fri, 8 Oct 2010 09:23:26 +0200
Subject: [PATCH] Fix problem with invalid read from array

This patch fix problem with reading data from out of the array range in
function used to create EIR response.
---
 src/sdpd-service.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index 26ab9a5..67dd9af 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -204,7 +204,7 @@ static void eir_generate_uuid128(sdp_list_t *list,
 		for (i = 0; i < index; i++) {
 			for (k = 0; k < SIZEOF_UUID128; k++) {
 				if (uuid128[i * SIZEOF_UUID128 + k] !=
-					uuid128_data[SIZEOF_UUID128 - k])
+					uuid128_data[SIZEOF_UUID128 - 1 - k])
 					break;
 			}
 			if (k == SIZEOF_UUID128)
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix problem with invalid read from array
  2010-10-08  8:35     ` Lukasz Pawlik
@ 2010-10-09 15:12       ` Johan Hedberg
  0 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2010-10-09 15:12 UTC (permalink / raw)
  To: Lukasz Pawlik; +Cc: linux-bluetooth

Hi Lukasz,

On Fri, Oct 08, 2010, Lukasz Pawlik wrote:
> Attaching patch without change in src/adapter.c file.

Thanks. The patch is now upstream.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-10-09 15:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-06 12:52 [PATCH] Fix problem with invalid read from array Lukasz Pawlik
2010-10-06 13:32 ` Johan Hedberg
2010-10-06 15:33   ` Lukasz Pawlik
2010-10-08  8:35     ` Lukasz Pawlik
2010-10-09 15:12       ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).