diff mbox series

uqmi: corrected too short received SMS

Message ID CAEJWX3G3hcOKqvf=5SgFFDdFGsDXWTRY8C8qu4MNvLrxc4j8Rw@mail.gmail.com
State Accepted
Delegated to: Daniel Golle
Headers show
Series uqmi: corrected too short received SMS | expand

Commit Message

Henrik Ginstmark March 11, 2022, 11:33 p.m. UTC
When characters with ascii values bigger than 0x7f are used, the
length of the received text
message is too short.

Test message sent: 123äÄ123
Before correction:
root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20
Raw text: 31 32 33 7b 5b 31 32 33
{
        "smsc": "+46724400001",
        "sender": "+46xxxxxxxxx",
        "timestamp": "2022-03-11 18:48:10",
        "text": "123äÄ1"
}

after correction:
root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20
Raw text: 31 32 33 7b 5b 31 32 33
{
        "smsc": "+46724400001",
        "sender": "+46xxxxxxxxx",
        "timestamp": "2022-03-11 18:48:10",
        "text": "123äÄ123"
}

Signed-off-by: Henrik Ginstmark <henrik@ginstmark.se>
---
 uqmi/src/commands-wms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

        blobmsg_add_string_buffer(&status);
 }

--
2.34.1

Comments

Daniel Golle March 12, 2022, 10:49 a.m. UTC | #1
Hi Henrik,

thank you for submitting this patch. I've also noticed that problem
long ago but it wasn't important for me at the time, so I didn't go
into fixing it.

On Sat, Mar 12, 2022 at 12:33:54AM +0100, Henrik Ginstmark wrote:
> When characters with ascii values bigger than 0x7f are used, the
> length of the received text
> message is too short.
> 
> Test message sent: 123äÄ123
> Before correction:
> root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20
> Raw text: 31 32 33 7b 5b 31 32 33
> {
>         "smsc": "+46724400001",
>         "sender": "+46xxxxxxxxx",
>         "timestamp": "2022-03-11 18:48:10",
>         "text": "123äÄ1"
> }
> 
> after correction:
> root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20
> Raw text: 31 32 33 7b 5b 31 32 33
> {
>         "smsc": "+46724400001",
>         "sender": "+46xxxxxxxxx",
>         "timestamp": "2022-03-11 18:48:10",
>         "text": "123äÄ123"
> }
> 
> Signed-off-by: Henrik Ginstmark <henrik@ginstmark.se>
> ---
>  uqmi/src/commands-wms.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/uqmi/src/commands-wms.c b/uqmi/src/commands-wms.c
> index 700d79f..a58fd6a 100644
> --- a/uqmi/src/commands-wms.c
> +++ b/uqmi/src/commands-wms.c
> @@ -222,8 +222,8 @@ static int decode_udh(const unsigned char *data)
>  static void decode_7bit_field(char *name, const unsigned char *data,
> int data_len, int bit_offset)

I've fixed the line-wrappign problems here ...

>  {
>         char *dest = blobmsg_alloc_string_buffer(&status, name, 3 *
> data_len + 2);

... and here ...
> -       pdu_decode_7bit_str(dest, data, CEILDIV(data_len * 7, 8), bit_offset);
> -       dest[data_len] = 0;
> +       int out_len = pdu_decode_7bit_str(dest, data, CEILDIV(data_len
> * 7, 8), bit_offset);

... and here, so the patch would apply.

> +       dest[out_len] = 0;
>         blobmsg_add_string_buffer(&status);
>  }
> 
> --
> 2.34.1

Please use 'git format-send-email' or 'git format-patch' next time to
avoid the MUA messing around with line-wrapping.
For this submission it's ok, I've already fixed it manually.


Cheers


Daniel
Henrik Ginstmark March 13, 2022, 1:06 p.m. UTC | #2
Thanks for the quick response.
Sorry about the line-wrapping. I need to lock into my git environment.

Cheers
Henrik

Den lör 12 mars 2022 kl 11:49 skrev Daniel Golle <daniel@makrotopia.org>:
>
> Hi Henrik,
>
> thank you for submitting this patch. I've also noticed that problem
> long ago but it wasn't important for me at the time, so I didn't go
> into fixing it.
>
> On Sat, Mar 12, 2022 at 12:33:54AM +0100, Henrik Ginstmark wrote:
> > When characters with ascii values bigger than 0x7f are used, the
> > length of the received text
> > message is too short.
> >
> > Test message sent: 123äÄ123
> > Before correction:
> > root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20
> > Raw text: 31 32 33 7b 5b 31 32 33
> > {
> >         "smsc": "+46724400001",
> >         "sender": "+46xxxxxxxxx",
> >         "timestamp": "2022-03-11 18:48:10",
> >         "text": "123äÄ1"
> > }
> >
> > after correction:
> > root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20
> > Raw text: 31 32 33 7b 5b 31 32 33
> > {
> >         "smsc": "+46724400001",
> >         "sender": "+46xxxxxxxxx",
> >         "timestamp": "2022-03-11 18:48:10",
> >         "text": "123äÄ123"
> > }
> >
> > Signed-off-by: Henrik Ginstmark <henrik@ginstmark.se>
> > ---
> >  uqmi/src/commands-wms.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/uqmi/src/commands-wms.c b/uqmi/src/commands-wms.c
> > index 700d79f..a58fd6a 100644
> > --- a/uqmi/src/commands-wms.c
> > +++ b/uqmi/src/commands-wms.c
> > @@ -222,8 +222,8 @@ static int decode_udh(const unsigned char *data)
> >  static void decode_7bit_field(char *name, const unsigned char *data,
> > int data_len, int bit_offset)
>
> I've fixed the line-wrappign problems here ...
>
> >  {
> >         char *dest = blobmsg_alloc_string_buffer(&status, name, 3 *
> > data_len + 2);
>
> ... and here ...
> > -       pdu_decode_7bit_str(dest, data, CEILDIV(data_len * 7, 8), bit_offset);
> > -       dest[data_len] = 0;
> > +       int out_len = pdu_decode_7bit_str(dest, data, CEILDIV(data_len
> > * 7, 8), bit_offset);
>
> ... and here, so the patch would apply.
>
> > +       dest[out_len] = 0;
> >         blobmsg_add_string_buffer(&status);
> >  }
> >
> > --
> > 2.34.1
>
> Please use 'git format-send-email' or 'git format-patch' next time to
> avoid the MUA messing around with line-wrapping.
> For this submission it's ok, I've already fixed it manually.
>
>
> Cheers
>
>
> Daniel
diff mbox series

Patch

diff --git a/uqmi/src/commands-wms.c b/uqmi/src/commands-wms.c
index 700d79f..a58fd6a 100644
--- a/uqmi/src/commands-wms.c
+++ b/uqmi/src/commands-wms.c
@@ -222,8 +222,8 @@  static int decode_udh(const unsigned char *data)
 static void decode_7bit_field(char *name, const unsigned char *data,
int data_len, int bit_offset)
 {
        char *dest = blobmsg_alloc_string_buffer(&status, name, 3 *
data_len + 2);
-       pdu_decode_7bit_str(dest, data, CEILDIV(data_len * 7, 8), bit_offset);
-       dest[data_len] = 0;
+       int out_len = pdu_decode_7bit_str(dest, data, CEILDIV(data_len
* 7, 8), bit_offset);
+       dest[out_len] = 0;