aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-05-26 00:55:20 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-05-28 06:50:41 +0700
commite4799f56030a1dc73c9ebf0092084dfaa332398d (patch)
treeb50b94893f74ca989a26e4a242050e996bceb960
parent719408745786159cb0471477e015e155c14935b6 (diff)
gsm48_decode_bcd_number2(): return -EINVAL if LV has too big length
-rw-r--r--src/gsm/gsm48_ie.c4
-rw-r--r--tests/gsm0408/gsm0408_test.c2
-rw-r--r--tests/gsm0408/gsm0408_test.ok4
3 files changed, 5 insertions, 5 deletions
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 @@ int gsm48_decode_bcd_number(char *output, int output_len,
*
* 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 @@ int gsm48_decode_bcd_number2(char *output, size_t output_len,
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 55c9b61..d7bae77 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -712,7 +712,7 @@ static const struct bcd_number_test {
.test_name = "LV incorrect length",
.dec_hex = "05214365", /* should be 0x03 */
.dec_ascii = "(none)",
- .dec_rc = -EIO,
+ .dec_rc = -EINVAL,
},
{
.test_name = "empty input buffer",
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index b080411..075886e 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -177,8 +177,8 @@ BSD number encoding / decoding test
- 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)'
- Running test: empty input buffer
- Encoding ASCII (buffer limit=0) ''...
- Expected: (rc=1) '00'