Module: kamailio
Branch: master
Commit: 2bebff2b27acd8ffa9f9d22409c197b0f0bc168e
URL:
https://github.com/kamailio/kamailio/commit/2bebff2b27acd8ffa9f9d22409c197b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-12-15T11:17:11+01:00
sms: rework truncating long messages
---
Modified: src/modules/sms/libsms_getsms.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2bebff2b27acd8ffa9f9d22409c197b…
Patch:
https://github.com/kamailio/kamailio/commit/2bebff2b27acd8ffa9f9d22409c197b…
---
diff --git a/src/modules/sms/libsms_getsms.c b/src/modules/sms/libsms_getsms.c
index 959d44f0333..0f6df6b7341 100644
--- a/src/modules/sms/libsms_getsms.c
+++ b/src/modules/sms/libsms_getsms.c
@@ -187,8 +187,10 @@ static int fetchsms(struct modem *mdm, int sim, char *pdu)
return 0;
/* Now we have the end of the PDU or ASCII string */
*end = 0;
- if(strlen(beginning) < SMS_BUF_SIZE) {
- strcpy(pdu, beginning);
+ clen = strlen(beginning);
+ if(clen < SMS_BUF_SIZE) {
+ memcpy(pdu, beginning, clen);
+ pdu[clen] = '\0';
} else {
/* truncate */
memcpy(pdu, beginning, SMS_BUF_SIZE - 1);