From f996b05dbddccb8e8788dd69777a4fedfa2373eb Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Thu, 4 Jul 2013 09:44:47 +0200 Subject: Fix encoding of last character at 7bit encoding function To avoid the situation where the receiving entity confuses 7 binary zero pad bits as the @ character, the carriage return or character shall be used for padding in this situation. --- src/gsm/gsm_utils.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gsm/gsm_utils.c') diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index 9569cf32..fa77eae4 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -241,6 +241,12 @@ int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len result[z++] = cb; shift++; } + /* To avoid the situation where the receiving entity confuses 7 binary + * zero pad bits as the @ character, the carriage return or + * character (defined in subclause 7.1.1) shall be used for padding in + * this situation. */ + if (shift == 7) + result[z - 1] |= 0x1a; free(data); -- cgit v1.2.3