2012-04-16 13:01:35

by Syam Sidhardhan

[permalink] [raw]
Subject: [PATCH BlueZ 0/3] SDP build warning and EIR parsing

This patchset is sending as per my discussion with Johan over the IRC#bluez.
The first patch is: While building the code with the maintainer mode enable,
is throwing warning and further it leads to a build break in different cross
compilation environment.

The second and third patch is related to the EIR parsing.
Since the eir_length() parsing return value is incorrect, we are appending
the COD at incorrect location. As a result, while retrieving back we are
unable to get the COD back during emiting device found signal during discovery.

The same fix is required in the eir_has_data_type() aswell.



Syam Sidhardhan (3):
sdp: Fix compilation warning due to data type mismatch
eir: Fix incorrect eir_length() parsing
eir: Fix incorrect eir_has_data_type() parsing

lib/sdp.c | 2 +-
src/eir.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)

--
1.7.4.1



2012-04-16 19:56:33

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH BlueZ 0/3] SDP build warning and EIR parsing

Hi Syam,

On Mon, Apr 16, 2012, Syam Sidhardhan wrote:
> This patchset is sending as per my discussion with Johan over the IRC#bluez.
> The first patch is: While building the code with the maintainer mode enable,
> is throwing warning and further it leads to a build break in different cross
> compilation environment.
>
> The second and third patch is related to the EIR parsing.
> Since the eir_length() parsing return value is incorrect, we are appending
> the COD at incorrect location. As a result, while retrieving back we are
> unable to get the COD back during emiting device found signal during discovery.
>
> The same fix is required in the eir_has_data_type() aswell.
>
> Syam Sidhardhan (3):
> sdp: Fix compilation warning due to data type mismatch
> eir: Fix incorrect eir_length() parsing
> eir: Fix incorrect eir_has_data_type() parsing
>
> lib/sdp.c | 2 +-
> src/eir.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)

Applied. Thanks.

Johan

2012-04-16 13:01:38

by Syam Sidhardhan

[permalink] [raw]
Subject: [PATCH BlueZ 3/3] eir: Fix incorrect eir_has_data_type() parsing

Updating the "parsed" variable twice inside the for loop, leads to
incorrect parsing.
---
src/eir.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index d622b08..cdf3e8f 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -343,9 +343,9 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
gboolean eir_has_data_type(uint8_t *data, size_t len, uint8_t type)
{
uint8_t field_len;
- size_t parsed;
+ size_t parsed = 0;

- for (parsed = 0; parsed < len - 1; parsed += field_len) {
+ while (parsed < len - 1) {
field_len = data[0];

if (field_len == 0)
--
1.7.4.1


2012-04-16 13:01:37

by Syam Sidhardhan

[permalink] [raw]
Subject: [PATCH BlueZ 2/3] eir: Fix incorrect eir_length() parsing

Issue:
The COD value displayed via dbus during inquiry is wrong.
This is because of the incorrect return length of the eir_length(),
which leads to appending the COD at wrong location.

Analysis:
After appending the COD at the end of the eir data, we can see
there are some '00' present in the eir field length in the eir file.
XX:XX:XX:XX:XX:XX 07095359414D5043020A040B0312111F110C110E110311
0000000000000000000000040D000142

Fix:
Corrected the length calculation in eir_length(), which is determining,
which position the COD should append
---
src/eir.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index 7b7b705..d622b08 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -379,9 +379,9 @@ size_t eir_append_data(uint8_t *eir, size_t eir_len, uint8_t type,
size_t eir_length(uint8_t *eir, size_t maxlen)
{
uint8_t field_len;
- size_t parsed, length;
+ size_t parsed = 0, length = 0;

- for (parsed = 0, length = 0; parsed < maxlen - 1; parsed += field_len) {
+ while (parsed < maxlen - 1) {
field_len = eir[0];

if (field_len == 0)
--
1.7.4.1


2012-04-16 13:01:36

by Syam Sidhardhan

[permalink] [raw]
Subject: [PATCH BlueZ 1/3] sdp: Fix compilation warning due to data type mismatch

In certain cross compiling environment, if we build the code with
enabling the maintainer mode, the following error happens.

cc1: warnings being treated as errors
lib/sdp.c: In function 'sdp_process':
lib/sdp.c:4111:6: error: comparison between signed and unsigned integer
expressions
make[2]: *** [lib/sdp.lo] Error 1
make[1]: *** [all] Error 2
---
lib/sdp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/sdp.c b/lib/sdp.c
index eaf8d00..81e328e 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -4108,7 +4108,7 @@ int sdp_process(sdp_session_t *session)
}

if (n == 0 || reqhdr->tid != rsphdr->tid ||
- (n != (ntohs(rsphdr->plen) + (int) sizeof(sdp_pdu_hdr_t)))) {
+ (n != (int) (ntohs(rsphdr->plen) + sizeof(sdp_pdu_hdr_t)))) {
t->err = EPROTO;
SDPERR("Protocol error.");
goto end;
--
1.7.4.1