[PATCH] rewritten gsm 7 bit encoding

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Nico Golde openbsc at ngolde.de
Tue Jul 20 11:04:52 UTC 2010


Hi,
* Holger Hans Peter Freyther <holger at freyther.de> [2010-07-20 13:03]:
> On 07/20/2010 05:05 AM, Nico Golde wrote:
> > I just looked into this and if I'm not mistaken this is no 
> > bug in the encoding but just a bug when comparing the 
> > encoded result. The current code memcmp's n bytes where n is 
> > the result of gsm_7bit_encode() with the input string 
> > bytewise. The problem with this is that the function returns 
> > the number of septets not octets. Attached is a patch for 
> > the test code that should fix this.
> 
> I don't think using strlen is correct. The gsm_7bit_encode
> method makes no promise that the result will have a null
> byte at the end, in fact nothing in this method will add a
> null byte, and the null byte in the output is only present
> because of memset in the calling method.

Yeah, realized this after writing, hence the second reply.

> I think gsm_7bit_encode should return the length of bytes
> it has written to, not more. :)

Yes and I think this is part of the problem. Currently the 
function returns i instead of z while z is the counter for 
the bytes actually written and i the number of encoded 
septets. I will probably look into this at the weekend.

Cheers
Nico




More information about the OpenBSC mailing list