[PATCH] umbim: fix invalid mbim message string encoding

Daniel Danzberger daniel at dd-wrt.com
Tue May 10 04:23:02 PDT 2022

On Tue, 2022-05-10 at 12:57 +0200, Bjørn Mork wrote:
>     Unless otherwise specified, all strings use UNICODE UTF-16LE
>     encodings limited to characters from the Basic Multilingual
>     Plane. Strings shall not be terminated by a NULL character.
> > +       /* convert to utf-16 little endian */
> >         for (i = 0; i < l; i++)
> > -               p[i * 2] = in[i];
> > +               p[i * 2] = htole16(in[i]);
> >  
> >         return 0;
> >  }
> This new code is buggy.  It fails on BE and makes no difference on
> LE. Both p and in are byte arrays. The byte you write into p on a BE
> system will be aither 0x00 or 0xff depending on the MSB of in[i].

True, I will remove that le16 conversion part and retest.
> The previous code was sort of correct, assuming that the input is mostly
> ascii mapping to the same value in unicode. Ideally we should do real
> utf16le conversion of the input. But then someone has to decide if the
> input is utf8 or something else first.  And you need a real utf16
> implementation.  Not sure it's worth it.  Did you ever see an operator
> use a non-ascii APN, username, password or pin code?
Agree, it's best for now to just leave it as is.


Daniel Danzberger
embeDD GmbH, Alter Postplatz 2, CH-6370 Stans

More information about the openwrt-devel mailing list