Increase PDU buffer size to fit 8-bit-encoded hex string

pull/11245/head
Marcin Radomski 2019-08-13 17:08:33 +02:00
parent cd7e6c9708
commit f3e9501ac6
1 changed files with 5 additions and 2 deletions

View File

@ -291,8 +291,11 @@ char *AT_CellularSMS::create_pdu(const char *phone_number, const char *message,
// there might be need for padding so some more space
totalPDULength += 2;
// message 7-bit padded and it will be converted to hex so it will take twice as much space
totalPDULength += (message_length - (message_length / 8)) * 2;
// 8-bit message, converted to hex so it will take twice as much space
totalPDULength += message_length * 2;
// terminating nullbyte, because callers use strlen() to find out PDU size
totalPDULength += 1;
char *pdu = new char[totalPDULength];
memset(pdu, 0, totalPDULength);