From fa6c2b9b53d577df916089a26a815e37277eb888 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Wed, 9 Aug 2017 17:38:39 +0600 Subject: gsm0480: fix USSD OCTET STRING length confusion According to the GSM 04.80 (version 5.0.0) specification Annex A "Expanded ASN.1 Module "SS-Protocol", the maximum size of a USSD OCTET STRING is 160 bytes. Thus according to ETSI TS 123 038 (version 10.0.0) specification 6.1.2.3 "USSD packing of 7 bit characters", in 160 octets, it's possible to pack (160 * 8) / 7 = 182.8, that is 182 characters. The remaining 6 bits are set to zero. This change defines both mentioned values: - GSM0480_USSD_OCTET_STRING_LEN 160 - GSM0480_USSD_7BIT_STRING_LEN 182 keeping the old MAX_LEN_USSD_STRING 'as is' due to compatibility reasons. Now the new value is used for ss_request structure, while old one is still used for deprecated ussd_request structure. Change-Id: I6dead74f9ecea079752ff2400cdaf7c30187784e --- src/gsm/gsm0480.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gsm/gsm0480.c') diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c index d7c29787..dcf487af 100644 --- a/src/gsm/gsm0480.c +++ b/src/gsm/gsm0480.c @@ -456,8 +456,8 @@ static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length, (uss_req_data[5] == ASN1_OCTET_STRING_TAG)) { num_chars = (uss_req_data[6] * 8) / 7; /* Prevent a mobile-originated buffer-overrun! */ - if (num_chars > MAX_LEN_USSD_STRING) - num_chars = MAX_LEN_USSD_STRING; + if (num_chars > GSM0480_USSD_7BIT_STRING_LEN) + num_chars = GSM0480_USSD_7BIT_STRING_LEN; gsm_7bit_decode_n_ussd((char *)req->ussd_text, sizeof(req->ussd_text), &(uss_req_data[7]), num_chars); -- cgit v1.2.3