Change in libosmocore[master]: gsm0408/gsm0408_test.c: introduce BCD number encoding / decoding test

Vadim Yanitskiy gerrit-no-reply at
Sat May 25 18:21:25 UTC 2019

Hello Pau Espin Pedrol, Neels Hofmeyr, Harald Welte, Jenkins Builder, 

I'd like you to reexamine a change. Please visit

to look at the new patch set (#2).

Change subject: gsm0408/gsm0408_test.c: introduce BCD number encoding / decoding test

gsm0408/gsm0408_test.c: introduce BCD number encoding / decoding test

So far, both gsm48_encode_bcd_number() and gsm48_decode_bcd_number2()
were uncovered by unit tests. Let's fill this gap by testing the
following scenarios:

  - encoding / decoding of a regular 6-digit MSISDN;
  - encoding / decoding of a long 15-digit MSISDN;
  - encoding / decoding of a MSISDN to a buffer:
    - with exactly matching size,
    - with lower size (truncation);
  - decoding LV buffer with incorrect length,
  - encoding / decoding an empty input buffer.

As it turns out, gsm48_decode_bcd_number2() does not properly
handle encoded LV if the output buffer size is equal to the
original MSISDN length + 1 (\0-terminator): one digit is lost.

For example, decoding of 15-digit long MSISDN to a buffer of size
16 (15 digits + 1 for \0) would give us only 14 digits. This is
reflected in the unit test output:

  Decoding HEX (buffer limit=16) '0821436587092143f5'...
    Expected: (rc=0) '123456789012345'
      Actual: (rc=0) '12345678901234'

Moreover, if the output buffer is shorter than decoded number,
gsm48_decode_bcd_number2() silently truncates it and returns 0,
while its description states, that the rc should reflect this.

To be fixed in the follow-up patches.

Change-Id: I4b2c330cf8ffe4427c0bee7d5f3b74be56ecd85d
Related: OS#4025
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 199 insertions(+), 0 deletions(-)

  git pull ssh:// refs/changes/84/14184/2
To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4b2c330cf8ffe4427c0bee7d5f3b74be56ecd85d
Gerrit-Change-Number: 14184
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy <axilirator at>
Gerrit-Reviewer: Harald Welte <laforge at>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list