2012-07-28 22:20:13

by Andrzej Kaczmarek

[permalink] [raw]
Subject: [PATCH hcidump] hci: Fix EIR data parsing

Data passed to ext_inquiry_data_dump are expected to start with length
octet which was consumed by get_u8.
---
parser/hci.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/parser/hci.c b/parser/hci.c
index 742a1b5..adcdaf7 100644
--- a/parser/hci.c
+++ b/parser/hci.c
@@ -831,16 +831,19 @@ static inline void ext_inquiry_response_dump(int level, struct frame *frm)
{
void *ptr = frm->ptr;
uint32_t len = frm->len;
+ uint8_t *data_ptr;
uint8_t length;

+ data_ptr = frm->ptr;
length = get_u8(frm);

while (length > 0) {
- ext_inquiry_data_dump(level, frm, frm->ptr);
+ ext_inquiry_data_dump(level, frm, data_ptr);

frm->ptr += length;
frm->len -= length;

+ data_ptr = frm->ptr;
length = get_u8(frm);
}

--
1.7.10



2012-07-28 23:42:26

by Vinicius Costa Gomes

[permalink] [raw]
Subject: Re: [PATCH hcidump] hci: Fix EIR data parsing

Hi Andrzej,

On 00:20 Sun 29 Jul, Andrzej Kaczmarek wrote:
> Data passed to ext_inquiry_data_dump are expected to start with length
> octet which was consumed by get_u8.

Good catch.

> ---
> parser/hci.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/parser/hci.c b/parser/hci.c
> index 742a1b5..adcdaf7 100644
> --- a/parser/hci.c
> +++ b/parser/hci.c
> @@ -831,16 +831,19 @@ static inline void ext_inquiry_response_dump(int level, struct frame *frm)
> {
> void *ptr = frm->ptr;
> uint32_t len = frm->len;
> + uint8_t *data_ptr;

Just a nitpick, I would only change 'data_ptr' to 'data', to make it more
consistent with the parameters names that ext_inquiry_data_dump() expects.

> uint8_t length;
>
> + data_ptr = frm->ptr;
> length = get_u8(frm);
>
> while (length > 0) {
> - ext_inquiry_data_dump(level, frm, frm->ptr);
> + ext_inquiry_data_dump(level, frm, data_ptr);
>
> frm->ptr += length;
> frm->len -= length;
>
> + data_ptr = frm->ptr;
> length = get_u8(frm);
> }
>
> --
> 1.7.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html


Cheers,
--
Vinicius