All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] mesh: Fix proxy PDU SAR msg length
@ 2018-03-16  8:14 Robert Lubaś
  2018-03-16  8:36 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Lubaś @ 2018-03-16  8:14 UTC (permalink / raw)
  To: linux-bluetooth

In read_pipe function there was a mishandled case when the msg has
more than one segment. As a result e.g. after provisioning the
capabilities discovery was incorrect parsed.

---
 mesh/gatt.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/mesh/gatt.c b/mesh/gatt.c
index 9116a9de1..8fecac10b 100644
--- a/mesh/gatt.c
+++ b/mesh/gatt.c
@@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
void *user_data)
        uint8_t buf[512];
        uint8_t *res;
        int fd = io_get_fd(io);
-       ssize_t len;
+       ssize_t len, len_sar;

        if (io != notify_io)
                return true;
@@ -393,14 +393,13 @@ static bool pipe_read(struct io *io, bool prov,
void *user_data)
                        break;

                res = buf;
-               mesh_gatt_sar(&res, len);
-
-               if (prov)
-                       prov_data_ready(node, res, len);
-               else
-                       net_data_ready(res, len);
+               if (len_sar = mesh_gatt_sar(&res, len)) {
+                       if (prov)
+                               prov_data_ready(node, res, len_sar);
+                       else
+                               net_data_ready(res, len_sar);
+               }
        }
-
        return true;
 }

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

* Re: [PATCH BlueZ] mesh: Fix proxy PDU SAR msg length
  2018-03-16  8:14 [PATCH BlueZ] mesh: Fix proxy PDU SAR msg length Robert Lubaś
@ 2018-03-16  8:36 ` Luiz Augusto von Dentz
  2018-03-16  9:53   ` Robert Lubaś
  2018-03-16  9:56   ` Robert Lubaś
  0 siblings, 2 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2018-03-16  8:36 UTC (permalink / raw)
  To: Robert Lubaś; +Cc: linux-bluetooth

Hi Robert,

On Fri, Mar 16, 2018 at 10:14 AM, Robert Luba=C5=9B <robert.lubas@silvair.c=
om> wrote:
> In read_pipe function there was a mishandled case when the msg has
> more than one segment. As a result e.g. after provisioning the
> capabilities discovery was incorrect parsed.
>
> ---
>  mesh/gatt.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/mesh/gatt.c b/mesh/gatt.c
> index 9116a9de1..8fecac10b 100644
> --- a/mesh/gatt.c
> +++ b/mesh/gatt.c
> @@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
> void *user_data)
>         uint8_t buf[512];
>         uint8_t *res;
>         int fd =3D io_get_fd(io);
> -       ssize_t len;
> +       ssize_t len, len_sar;
>
>         if (io !=3D notify_io)
>                 return true;
> @@ -393,14 +393,13 @@ static bool pipe_read(struct io *io, bool prov,
> void *user_data)
>                         break;
>
>                 res =3D buf;
> -               mesh_gatt_sar(&res, len);
> -
> -               if (prov)
> -                       prov_data_ready(node, res, len);
> -               else
> -                       net_data_ready(res, len);
> +               if (len_sar =3D mesh_gatt_sar(&res, len)) {

Leave the assignment outside of if statement like:

len_sar =3D...
if (len_sar)...

> +                       if (prov)
> +                               prov_data_ready(node, res, len_sar);
> +                       else
> +                               net_data_ready(res, len_sar);
> +               }
>         }
> -
>         return true;
>  }

Other than that it looks fine.

--=20
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ] mesh: Fix proxy PDU SAR msg length
  2018-03-16  8:36 ` Luiz Augusto von Dentz
@ 2018-03-16  9:53   ` Robert Lubaś
  2018-03-16  9:56   ` Robert Lubaś
  1 sibling, 0 replies; 6+ messages in thread
From: Robert Lubaś @ 2018-03-16  9:53 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Assignment outside if statement.
---
 mesh/gatt.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mesh/gatt.c b/mesh/gatt.c
index 9116a9de1..693577a3a 100644
--- a/mesh/gatt.c
+++ b/mesh/gatt.c
@@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
void *user_data)
        uint8_t buf[512];
        uint8_t *res;
        int fd =3D io_get_fd(io);
-       ssize_t len;
+       ssize_t len, len_sar;

        if (io !=3D notify_io)
                return true;
@@ -393,14 +393,14 @@ static bool pipe_read(struct io *io, bool prov,
void *user_data)
                        break;

                res =3D buf;
-               mesh_gatt_sar(&res, len);
-
-               if (prov)
-                       prov_data_ready(node, res, len);
-               else
-                       net_data_ready(res, len);
+               len_sar =3D mesh_gatt_sar(&res, len);
+               if (len_sar) {
+                       if (prov)
+                               prov_data_ready(node, res, len_sar);
+                       else
+                               net_data_ready(res, len_sar);
+               }
        }
-
        return true;
 }


2018-03-16 9:36 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
> Hi Robert,
>
> On Fri, Mar 16, 2018 at 10:14 AM, Robert Luba=C5=9B <robert.lubas@silvair=
.com> wrote:
>> In read_pipe function there was a mishandled case when the msg has
>> more than one segment. As a result e.g. after provisioning the
>> capabilities discovery was incorrect parsed.
>>
>> ---
>>  mesh/gatt.c | 15 +++++++--------
>>  1 file changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/mesh/gatt.c b/mesh/gatt.c
>> index 9116a9de1..8fecac10b 100644
>> --- a/mesh/gatt.c
>> +++ b/mesh/gatt.c
>> @@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
>> void *user_data)
>>         uint8_t buf[512];
>>         uint8_t *res;
>>         int fd =3D io_get_fd(io);
>> -       ssize_t len;
>> +       ssize_t len, len_sar;
>>
>>         if (io !=3D notify_io)
>>                 return true;
>> @@ -393,14 +393,13 @@ static bool pipe_read(struct io *io, bool prov,
>> void *user_data)
>>                         break;
>>
>>                 res =3D buf;
>> -               mesh_gatt_sar(&res, len);
>> -
>> -               if (prov)
>> -                       prov_data_ready(node, res, len);
>> -               else
>> -                       net_data_ready(res, len);
>> +               if (len_sar =3D mesh_gatt_sar(&res, len)) {
>
> Leave the assignment outside of if statement like:
>
> len_sar =3D...
> if (len_sar)...
>
>> +                       if (prov)
>> +                               prov_data_ready(node, res, len_sar);
>> +                       else
>> +                               net_data_ready(res, len_sar);
>> +               }
>>         }
>> -
>>         return true;
>>  }
>
> Other than that it looks fine.
>
> --
> Luiz Augusto von Dentz



--=20
Robert Luba=C5=9B
Software Developer

Silvair by Seed Labs
Jasnog=C3=B3rska 44
31-358 Krakow
POLAND

www.silvair.com

NOTICE TO RECIPIENT | This e-mail message and any documents
accompanying it contain information that belongs to Seed Labs. This
e-mail is meant for only the intended recipient of the transmission,
and may be a communication privileged by law, confidential and/or
otherwise protected from disclosure. If you received this e-mail in
error and you are not the intended recipient, any review, use,
dissemination, distribution, or copying of this e-mail or attachment
is strictly prohibited. Please notify us immediately of the error by
return e-mail and please delete this message from your system.
Please consider the environmental impact before printing this document
and its attachment(s).Print black and white and double-sided where
possible.

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

* Re: [PATCH BlueZ] mesh: Fix proxy PDU SAR msg length
  2018-03-16  8:36 ` Luiz Augusto von Dentz
  2018-03-16  9:53   ` Robert Lubaś
@ 2018-03-16  9:56   ` Robert Lubaś
  2018-03-19  5:51     ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 6+ messages in thread
From: Robert Lubaś @ 2018-03-16  9:56 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Assignment outside if statement.
---
 mesh/gatt.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mesh/gatt.c b/mesh/gatt.c
index 9116a9de1..693577a3a 100644
--- a/mesh/gatt.c
+++ b/mesh/gatt.c
@@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
void *user_data)
        uint8_t buf[512];
        uint8_t *res;
        int fd =3D io_get_fd(io);
-       ssize_t len;
+       ssize_t len, len_sar;

        if (io !=3D notify_io)
                return true;
@@ -393,14 +393,14 @@ static bool pipe_read(struct io *io, bool prov,
void *user_data)
                        break;

                res =3D buf;
-               mesh_gatt_sar(&res, len);
-
-               if (prov)
-                       prov_data_ready(node, res, len);
-               else
-                       net_data_ready(res, len);
+               len_sar =3D mesh_gatt_sar(&res, len);
+               if (len_sar) {
+                       if (prov)
+                               prov_data_ready(node, res, len_sar);
+                       else
+                               net_data_ready(res, len_sar);
+               }
        }
-
        return true;
 }

2018-03-16 9:36 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
>
> Hi Robert,
>
> On Fri, Mar 16, 2018 at 10:14 AM, Robert Luba=C5=9B <robert.lubas@silvair=
.com> wrote:
> > In read_pipe function there was a mishandled case when the msg has
> > more than one segment. As a result e.g. after provisioning the
> > capabilities discovery was incorrect parsed.
> >
> > ---
> >  mesh/gatt.c | 15 +++++++--------
> >  1 file changed, 7 insertions(+), 8 deletions(-)
> >
> > diff --git a/mesh/gatt.c b/mesh/gatt.c
> > index 9116a9de1..8fecac10b 100644
> > --- a/mesh/gatt.c
> > +++ b/mesh/gatt.c
> > @@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
> > void *user_data)
> >         uint8_t buf[512];
> >         uint8_t *res;
> >         int fd =3D io_get_fd(io);
> > -       ssize_t len;
> > +       ssize_t len, len_sar;
> >
> >         if (io !=3D notify_io)
> >                 return true;
> > @@ -393,14 +393,13 @@ static bool pipe_read(struct io *io, bool prov,
> > void *user_data)
> >                         break;
> >
> >                 res =3D buf;
> > -               mesh_gatt_sar(&res, len);
> > -
> > -               if (prov)
> > -                       prov_data_ready(node, res, len);
> > -               else
> > -                       net_data_ready(res, len);
> > +               if (len_sar =3D mesh_gatt_sar(&res, len)) {
>
> Leave the assignment outside of if statement like:
>
> len_sar =3D...
> if (len_sar)...
>
> > +                       if (prov)
> > +                               prov_data_ready(node, res, len_sar);
> > +                       else
> > +                               net_data_ready(res, len_sar);
> > +               }
> >         }
> > -
> >         return true;
> >  }
>
> Other than that it looks fine.
>
> --
> Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ] mesh: Fix proxy PDU SAR msg length
  2018-03-16  9:56   ` Robert Lubaś
@ 2018-03-19  5:51     ` Luiz Augusto von Dentz
  2018-03-19 11:39       ` Robert Lubaś
  0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2018-03-19  5:51 UTC (permalink / raw)
  To: Robert Lubaś; +Cc: linux-bluetooth

Hi Robert,

On Fri, Mar 16, 2018 at 11:56 AM, Robert Luba=C5=9B <robert.lubas@silvair.c=
om> wrote:
> Assignment outside if statement.
> ---
>  mesh/gatt.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/mesh/gatt.c b/mesh/gatt.c
> index 9116a9de1..693577a3a 100644
> --- a/mesh/gatt.c
> +++ b/mesh/gatt.c
> @@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
> void *user_data)
>         uint8_t buf[512];
>         uint8_t *res;
>         int fd =3D io_get_fd(io);
> -       ssize_t len;
> +       ssize_t len, len_sar;
>
>         if (io !=3D notify_io)
>                 return true;
> @@ -393,14 +393,14 @@ static bool pipe_read(struct io *io, bool prov,
> void *user_data)
>                         break;
>
>                 res =3D buf;
> -               mesh_gatt_sar(&res, len);
> -
> -               if (prov)
> -                       prov_data_ready(node, res, len);
> -               else
> -                       net_data_ready(res, len);
> +               len_sar =3D mesh_gatt_sar(&res, len);
> +               if (len_sar) {
> +                       if (prov)
> +                               prov_data_ready(node, res, len_sar);
> +                       else
> +                               net_data_ready(res, len_sar);
> +               }
>         }
> -
>         return true;
>  }

Looks like you responded with the new patch instead of sending just
the changes an as a result I cannot apply the patch with git am,
perhaps you are not using git format-patch + git send-email?

> 2018-03-16 9:36 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
>>
>> Hi Robert,
>>
>> On Fri, Mar 16, 2018 at 10:14 AM, Robert Luba=C5=9B <robert.lubas@silvai=
r.com> wrote:
>> > In read_pipe function there was a mishandled case when the msg has
>> > more than one segment. As a result e.g. after provisioning the
>> > capabilities discovery was incorrect parsed.
>> >
>> > ---
>> >  mesh/gatt.c | 15 +++++++--------
>> >  1 file changed, 7 insertions(+), 8 deletions(-)
>> >
>> > diff --git a/mesh/gatt.c b/mesh/gatt.c
>> > index 9116a9de1..8fecac10b 100644
>> > --- a/mesh/gatt.c
>> > +++ b/mesh/gatt.c
>> > @@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
>> > void *user_data)
>> >         uint8_t buf[512];
>> >         uint8_t *res;
>> >         int fd =3D io_get_fd(io);
>> > -       ssize_t len;
>> > +       ssize_t len, len_sar;
>> >
>> >         if (io !=3D notify_io)
>> >                 return true;
>> > @@ -393,14 +393,13 @@ static bool pipe_read(struct io *io, bool prov,
>> > void *user_data)
>> >                         break;
>> >
>> >                 res =3D buf;
>> > -               mesh_gatt_sar(&res, len);
>> > -
>> > -               if (prov)
>> > -                       prov_data_ready(node, res, len);
>> > -               else
>> > -                       net_data_ready(res, len);
>> > +               if (len_sar =3D mesh_gatt_sar(&res, len)) {
>>
>> Leave the assignment outside of if statement like:
>>
>> len_sar =3D...
>> if (len_sar)...
>>
>> > +                       if (prov)
>> > +                               prov_data_ready(node, res, len_sar);
>> > +                       else
>> > +                               net_data_ready(res, len_sar);
>> > +               }
>> >         }
>> > -
>> >         return true;
>> >  }
>>
>> Other than that it looks fine.
>>
>> --
>> Luiz Augusto von Dentz



--=20
Luiz Augusto von Dentz

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

* Re: [PATCH BlueZ] mesh: Fix proxy PDU SAR msg length
  2018-03-19  5:51     ` Luiz Augusto von Dentz
@ 2018-03-19 11:39       ` Robert Lubaś
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Lubaś @ 2018-03-19 11:39 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

You right, I posted a second version of the patch using right tools.

2018-03-19 6:51 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
> Hi Robert,
>
> On Fri, Mar 16, 2018 at 11:56 AM, Robert Luba=C5=9B <robert.lubas@silvair=
.com> wrote:
>> Assignment outside if statement.
>> ---
>>  mesh/gatt.c | 16 ++++++++--------
>>  1 file changed, 8 insertions(+), 8 deletions(-)
>>
>> diff --git a/mesh/gatt.c b/mesh/gatt.c
>> index 9116a9de1..693577a3a 100644
>> --- a/mesh/gatt.c
>> +++ b/mesh/gatt.c
>> @@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
>> void *user_data)
>>         uint8_t buf[512];
>>         uint8_t *res;
>>         int fd =3D io_get_fd(io);
>> -       ssize_t len;
>> +       ssize_t len, len_sar;
>>
>>         if (io !=3D notify_io)
>>                 return true;
>> @@ -393,14 +393,14 @@ static bool pipe_read(struct io *io, bool prov,
>> void *user_data)
>>                         break;
>>
>>                 res =3D buf;
>> -               mesh_gatt_sar(&res, len);
>> -
>> -               if (prov)
>> -                       prov_data_ready(node, res, len);
>> -               else
>> -                       net_data_ready(res, len);
>> +               len_sar =3D mesh_gatt_sar(&res, len);
>> +               if (len_sar) {
>> +                       if (prov)
>> +                               prov_data_ready(node, res, len_sar);
>> +                       else
>> +                               net_data_ready(res, len_sar);
>> +               }
>>         }
>> -
>>         return true;
>>  }
>
> Looks like you responded with the new patch instead of sending just
> the changes an as a result I cannot apply the patch with git am,
> perhaps you are not using git format-patch + git send-email?
>
>> 2018-03-16 9:36 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
>>>
>>> Hi Robert,
>>>
>>> On Fri, Mar 16, 2018 at 10:14 AM, Robert Luba=C5=9B <robert.lubas@silva=
ir.com> wrote:
>>> > In read_pipe function there was a mishandled case when the msg has
>>> > more than one segment. As a result e.g. after provisioning the
>>> > capabilities discovery was incorrect parsed.
>>> >
>>> > ---
>>> >  mesh/gatt.c | 15 +++++++--------
>>> >  1 file changed, 7 insertions(+), 8 deletions(-)
>>> >
>>> > diff --git a/mesh/gatt.c b/mesh/gatt.c
>>> > index 9116a9de1..8fecac10b 100644
>>> > --- a/mesh/gatt.c
>>> > +++ b/mesh/gatt.c
>>> > @@ -383,7 +383,7 @@ static bool pipe_read(struct io *io, bool prov,
>>> > void *user_data)
>>> >         uint8_t buf[512];
>>> >         uint8_t *res;
>>> >         int fd =3D io_get_fd(io);
>>> > -       ssize_t len;
>>> > +       ssize_t len, len_sar;
>>> >
>>> >         if (io !=3D notify_io)
>>> >                 return true;
>>> > @@ -393,14 +393,13 @@ static bool pipe_read(struct io *io, bool prov,
>>> > void *user_data)
>>> >                         break;
>>> >
>>> >                 res =3D buf;
>>> > -               mesh_gatt_sar(&res, len);
>>> > -
>>> > -               if (prov)
>>> > -                       prov_data_ready(node, res, len);
>>> > -               else
>>> > -                       net_data_ready(res, len);
>>> > +               if (len_sar =3D mesh_gatt_sar(&res, len)) {
>>>
>>> Leave the assignment outside of if statement like:
>>>
>>> len_sar =3D...
>>> if (len_sar)...
>>>
>>> > +                       if (prov)
>>> > +                               prov_data_ready(node, res, len_sar);
>>> > +                       else
>>> > +                               net_data_ready(res, len_sar);
>>> > +               }
>>> >         }
>>> > -
>>> >         return true;
>>> >  }
>>>
>>> Other than that it looks fine.
>>>
>>> --
>>> Luiz Augusto von Dentz
>
>
>
> --
> Luiz Augusto von Dentz

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

end of thread, other threads:[~2018-03-19 11:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-16  8:14 [PATCH BlueZ] mesh: Fix proxy PDU SAR msg length Robert Lubaś
2018-03-16  8:36 ` Luiz Augusto von Dentz
2018-03-16  9:53   ` Robert Lubaś
2018-03-16  9:56   ` Robert Lubaś
2018-03-19  5:51     ` Luiz Augusto von Dentz
2018-03-19 11:39       ` Robert Lubaś

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.