summaryrefslogtreecommitdiffstats
path: root/src/gsm_utils.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther2010-07-19 20:54:54 +0200
committerHolger Hans Peter Freyther2010-07-19 20:54:54 +0200
commit446bf376984c0ab0453ec79577b590225e36d991 (patch)
tree01ee58f769d27d98933ee1fde39fd6e22d5a462a /src/gsm_utils.c
parenttests: Separate encoding/decoding test to verify them independly (diff)
downloadlibosmocore-446bf376984c0ab0453ec79577b590225e36d991.tar.gz
libosmocore-446bf376984c0ab0453ec79577b590225e36d991.tar.xz
libosmocore-446bf376984c0ab0453ec79577b590225e36d991.zip
gsm_7bit_decode: Handle the case of the last charachter being an escape
If i + 1 == length and it is an escape charachter we would try to read rtext[length] which is one after the field we have allocated.
Diffstat (limited to 'src/gsm_utils.c')
-rw-r--r--src/gsm_utils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gsm_utils.c b/src/gsm_utils.c
index fb69377..3a378ac 100644
--- a/src/gsm_utils.c
+++ b/src/gsm_utils.c
@@ -65,7 +65,7 @@ int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t length)
}
for(i = 0; i < length; i++){
/* this is an extension character */
- if(rtext[i] == 0x1b){
+ if(rtext[i] == 0x1b && i + 1 < length){
tmp = rtext[i+1];
*(text++) = gsm_7bit_alphabet[0x7f + tmp];
i++;