summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-07-29 04:43:48 +0600
committerHarald Welte <laforge@gnumonks.org>2018-01-17 10:45:39 +0000
commit01b85724afbc4171ab77fcc63ebf7ccd82edefbe (patch)
tree9034636b1862de08790ef36d2e2536d225b2d9a1
parent5b0790df523b82f327ddc8e7d538380101ac2cae (diff)
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
-rw-r--r--src/gsm/gsm0480.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 11c66e94..b0b28e43 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -453,9 +453,18 @@ static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
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 @@ static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
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;