<p>Vadim Yanitskiy <strong>uploaded patch set #2</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/14184">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gsm0408/gsm0408_test.c: introduce BCD number encoding / decoding test<br><br>So far, both gsm48_encode_bcd_number() and gsm48_decode_bcd_number2()<br>were uncovered by unit tests. Let's fill this gap by testing the<br>following scenarios:<br><br>  - encoding / decoding of a regular 6-digit MSISDN;<br>  - encoding / decoding of a long 15-digit MSISDN;<br>  - encoding / decoding of a MSISDN to a buffer:<br>    - with exactly matching size,<br>    - with lower size (truncation);<br>  - decoding LV buffer with incorrect length,<br>  - encoding / decoding an empty input buffer.<br><br>As it turns out, gsm48_decode_bcd_number2() does not properly<br>handle encoded LV if the output buffer size is equal to the<br>original MSISDN length + 1 (\0-terminator): one digit is lost.<br><br>For example, decoding of 15-digit long MSISDN to a buffer of size<br>16 (15 digits + 1 for \0) would give us only 14 digits. This is<br>reflected in the unit test output:<br><br>  Decoding HEX (buffer limit=16) '0821436587092143f5'...<br>    Expected: (rc=0) '123456789012345'<br>      Actual: (rc=0) '12345678901234'<br><br>Moreover, if the output buffer is shorter than decoded number,<br>gsm48_decode_bcd_number2() silently truncates it and returns 0,<br>while its description states, that the rc should reflect this.<br><br>To be fixed in the follow-up patches.<br><br>Change-Id: I4b2c330cf8ffe4427c0bee7d5f3b74be56ecd85d<br>Related: OS#4025<br>---<br>M tests/gsm0408/gsm0408_test.c<br>M tests/gsm0408/gsm0408_test.ok<br>2 files changed, 199 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/14184/2</pre><p>To view, visit <a href="https://gerrit.osmocom.org/14184">change 14184</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/14184"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>
<div style="display:none"> Gerrit-Change-Id: I4b2c330cf8ffe4427c0bee7d5f3b74be56ecd85d </div>
<div style="display:none"> Gerrit-Change-Number: 14184 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>