Skip to content

Commit 7de9c6b

Browse files
committed
tom_modem: fix pdu decoding issue #124
1 parent 7c469b9 commit 7de9c6b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

application/tom_modem/src/operations.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ int sms_read(PROFILE_T *profile, void *transport_ptr)
117117
sms->sms_pdu = (char *)malloc(strlen(pdu));
118118
sms->sender = (char *)malloc(PHONE_NUMBER_SIZE);
119119
sms->sms_text = (char *)malloc(SMS_TEXT_SIZE);
120+
memset(sms->sms_text, 0, SMS_TEXT_SIZE);
120121
sms->sms_index = get_sms_index(line);
121122
memcpy(sms->sms_pdu, pdu, strlen(pdu));
122123
int sms_len = decode_pdu(sms);
@@ -237,6 +238,7 @@ int sms_read_unread(PROFILE_T *profile, void *transport_ptr)
237238
sms->sms_pdu = (char *)malloc(strlen(pdu));
238239
sms->sender = (char *)malloc(PHONE_NUMBER_SIZE);
239240
sms->sms_text = (char *)malloc(SMS_TEXT_SIZE);
241+
memset(sms->sms_text, 0, SMS_TEXT_SIZE);
240242
sms->sms_index = get_sms_index(line);
241243
memcpy(sms->sms_pdu, pdu, strlen(pdu));
242244
int sms_len = decode_pdu(sms);

application/tom_modem/src/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int decode_pdu(SMS_T *sms)
117117
// UCS2
118118
sms->type = SMS_CHARSET_UCS2;
119119
int offset = 0;
120-
for (int i = skip_bytes; i < SMS_TEXT_SIZE; i += 2)
120+
for (int i = skip_bytes; i < sms_len; i += 2)
121121
{
122122
int ucs2_char = 0x000000FF & sms_text[i + 1];
123123
ucs2_char |= (0x0000FF00 & (sms_text[i] << 8));

0 commit comments

Comments
 (0)