From 446bf376984c0ab0453ec79577b590225e36d991 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 20 Jul 2010 02:54:54 +0800 Subject: 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. --- src/gsm_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gsm_utils.c b/src/gsm_utils.c index fb69377f..3a378ace 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++; -- cgit v1.2.3