Change in libosmocore[master]: gsm48_encode_bcd_number(): zero-initialize optional header between L ...

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Sat May 25 19:03:17 UTC 2019


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/14189


Change subject: gsm48_encode_bcd_number(): zero-initialize optional header between L and V
......................................................................

gsm48_encode_bcd_number(): zero-initialize optional header between L and V

Change-Id: Iafd911dd55691b3715391e3899cd6971245c8d7f
---
M src/gsm/gsm48_ie.c
M tests/gsm0408/gsm0408_test.ok
M tests/sms/sms_test.ok
3 files changed, 8 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/89/14189/1

diff --git a/src/gsm/gsm48_ie.c b/src/gsm/gsm48_ie.c
index 688698d..77cd472 100644
--- a/src/gsm/gsm48_ie.c
+++ b/src/gsm/gsm48_ie.c
@@ -161,6 +161,10 @@
 	if (i % 2)
 		*bcd_cur++ |= 0xf0;
 
+	/* zero-initialize optional header between L and V */
+	for (i = 0; i < h_len; i++)
+		bcd_lv[i + 1] = 0x00;
+
 	/* return how many bytes we used */
 	return (bcd_cur - bcd_lv);
 }
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 075886e..8a65399 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -150,7 +150,7 @@
 - Running test: regular 6-digit MSISDN with optional header (LHV)
   - Encoding ASCII (buffer limit=0) '123456'...
     - Expected: (rc=8) '0700000000214365'
-    -   Actual: (rc=8) '0721436587214365'
+    -   Actual: (rc=8) '0700000000214365'
   - Decoding HEX (buffer limit=0) '07deadbeef214365'...
     - Expected: (rc=0) '123456'
     -   Actual: (rc=0) '123456'
diff --git a/tests/sms/sms_test.ok b/tests/sms/sms_test.ok
index a71567d..0a45c01 100644
--- a/tests/sms/sms_test.ok
+++ b/tests/sms/sms_test.ok
@@ -13,9 +13,9 @@
 SEPTETS: 8 OCTETS: 7
 Done
 Testing gsm340_gen_oa
-Result: len(12) data(14 81 21 43 65 87 09 21 43 65 87 19 )
-Result: len(12) data(14 a1 21 43 65 87 09 21 43 65 87 19 )
-Result: len(2) data(00 91 )
+Result: len(12) data(14 00 21 43 65 87 09 21 43 65 87 19 )
+Result: len(12) data(14 00 21 43 65 87 09 21 43 65 87 19 )
+Result: len(2) data(00 00 )
 Result: len(9) data(0e d0 4f 78 d9 2d 9c 0e 01 )
 Result: len(12) data(14 d0 4f 78 d9 2d 9c 0e c3 e2 31 19 )
 OK

-- 
To view, visit https://gerrit.osmocom.org/14189
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iafd911dd55691b3715391e3899cd6971245c8d7f
Gerrit-Change-Number: 14189
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190525/66f4235e/attachment.html>


More information about the gerrit-log mailing list