Module: kamailio
Branch: master
Commit: 192b681ce7fcd868a4a47a7c26863c733321b8d4
URL:
https://github.com/kamailio/kamailio/commit/192b681ce7fcd868a4a47a7c26863c7…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2023-07-26T15:00:38+02:00
sipcapture: make sure we null terminate the copy of the string
bug introduced at cbd7810fff3d5145c1ce34c0e362b5590bb92a12
---
Modified: src/modules/sipcapture/sipcapture.c
---
Diff:
https://github.com/kamailio/kamailio/commit/192b681ce7fcd868a4a47a7c26863c7…
Patch:
https://github.com/kamailio/kamailio/commit/192b681ce7fcd868a4a47a7c26863c7…
---
diff --git a/src/modules/sipcapture/sipcapture.c b/src/modules/sipcapture/sipcapture.c
index de0a15174cc..5efb1898036 100644
--- a/src/modules/sipcapture/sipcapture.c
+++ b/src/modules/sipcapture/sipcapture.c
@@ -2252,7 +2252,8 @@ static int sip_capture(
ip.s = ip_addr2a(&msg->rcv.src_ip);
ip.len = strlen(ip.s);
- memcpy(buf_ip, ip.s, ip.len);
+ /* Copy, including teminating \0 */
+ memcpy(buf_ip, ip.s, ip.len + 1);
sco.source_ip.s = buf_ip;
sco.source_ip.len = ip.len;
sco.source_port = msg->rcv.src_port;
@@ -2839,7 +2840,8 @@ static int report_capture(sip_msg_t *msg, str *_table, str *_corr,
str *_data)
/* IP source and destination */
ip.s = ip_addr2a(&msg->rcv.src_ip);
ip.len = strlen(ip.s);
- memcpy(buf_ip, ip.s, ip.len);
+ /* Copy, including teminating \0 */
+ memcpy(buf_ip, ip.s, ip.len + 1);
sco.source_ip.s = buf_ip;
sco.source_ip.len = ip.len;
sco.source_port = msg->rcv.src_port;