Change in libosmocore[master]: gsm48_decode_bcd_number2(): return -EINVAL if LV has too big length

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


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


Change subject: gsm48_decode_bcd_number2(): return -EINVAL if LV has too big length
......................................................................

gsm48_decode_bcd_number2(): return -EINVAL if LV has too big length

Change-Id: Ie07b2e8bc2f9628904e88448b4ee63b359655123
---
M src/gsm/gsm48_ie.c
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
3 files changed, 5 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/14187/1

diff --git a/src/gsm/gsm48_ie.c b/src/gsm/gsm48_ie.c
index 311836d..688698d 100644
--- a/src/gsm/gsm48_ie.c
+++ b/src/gsm/gsm48_ie.c
@@ -70,7 +70,7 @@
  *
  * Errors checked:
  *   - no or too little input data (-EIO),
- *   - IE length exceeds input data size (-EIO),
+ *   - IE length exceeds input data size (-EINVAL),
  *   - no or too little output buffer size (-ENOSPC),
  *   - decoded number exceeds size of the output buffer (-ENOSPC).
  *
@@ -90,7 +90,7 @@
 	in_len = bcd_lv[0];
 	/* len + 1: the BCD length plus the length byte itself must fit in the input buffer. */
 	if (input_len < in_len + 1)
-		return -EIO;
+		return -EINVAL;
 
 	for (i = 1 + h_len; i <= in_len; i++) {
 		/* lower nibble */
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index e77fe24..a4d0d2e 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -694,7 +694,7 @@
 		.test_name = "LV incorrect length",
 		.dec_hex   = "05214365", /* should be 0x03 */
 		.dec_ascii = "(none)",
-		.dec_rc    = -EIO,
+		.dec_rc    = -EINVAL,
 	},
 };
 
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index d16fe0a..bf1118f 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -170,8 +170,8 @@
     -   Actual: (rc=-28) '123456789012345'
 - Running test: LV incorrect length
   - Decoding HEX (buffer limit=0) '05214365'...
-    - Expected: (rc=-5) '(none)'
-    -   Actual: (rc=-5) '(none)'
+    - Expected: (rc=-22) '(none)'
+    -   Actual: (rc=-22) '(none)'
 
 Constructed RA:
 077-121-666-5

-- 
To view, visit https://gerrit.osmocom.org/14187
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: Ie07b2e8bc2f9628904e88448b4ee63b359655123
Gerrit-Change-Number: 14187
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/a578a677/attachment.html>


More information about the gerrit-log mailing list