Harald Welte has submitted this change and it was merged.

Change subject: gsm0480: handle UnstructuredSS Request with DSC != 0x0F
......................................................................


gsm0480: handle UnstructuredSS Request with DSC != 0x0F

According to GSM 04.08, 4.4.2 "ASN.1 data types":
the USSD-DataCodingScheme shall indicate use of
the default alphabet using the 0x0F value.

Previously, the UnstructuredSS Request messages with not
default alphabet were not being handled. Let's fix this.

Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
---
M src/gsm/gsm0480.c
1 file changed, 20 insertions(+), 0 deletions(-)

Approvals:
  Alexander Chemeris: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 11c66e9..b0b28e4 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -453,9 +453,18 @@
        if ((uss_req_data[2] & uss_req_data[5]) != ASN1_OCTET_STRING_TAG)
                return 0;
 
+       /* Get DCS (Data Coding Scheme) */
        dcs = uss_req_data[4];
+
+       /**
+        * According to GSM 04.08, 4.4.2 "ASN.1 data types":
+        * the USSD-DataCodingScheme shall indicate use of
+        * the default alphabet using the 0x0F value.
+        */
        if (dcs == 0x0F) {
+               /* Calculate the amount of 7-bit characters */
                num_chars = (uss_req_data[6] * 8) / 7;
+
                /* Prevent a mobile-originated buffer-overrun! */
                if (num_chars > GSM0480_USSD_7BIT_STRING_LEN)
                        num_chars = GSM0480_USSD_7BIT_STRING_LEN;
@@ -464,6 +473,17 @@
                        sizeof(req->ussd_text), &(uss_req_data[7]), num_chars);
 
                return 1;
+       } else {
+               /* Get the amount of 8-bit characters */
+               num_chars = uss_req_data[6];
+
+               /* Prevent a mobile-originated buffer-overrun! */
+               if (num_chars > GSM0480_USSD_OCTET_STRING_LEN)
+                       num_chars = GSM0480_USSD_OCTET_STRING_LEN;
+
+               memcpy(req->ussd_text, &(uss_req_data[7]), num_chars);
+
+               return 1;
        }
 
        return 0;

-- 
To view, visit https://gerrit.osmocom.org/3376
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
Gerrit-PatchSet: 10
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilira...@gmail.com>
Gerrit-Reviewer: Alexander Chemeris <alexander.cheme...@gmail.com>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Ivan Kluchnikov <kluchnik...@gmail.com>
Gerrit-Reviewer: Jenkins Builder

Reply via email to