Module: kamailio
Branch: master
Commit: 219072f0ef43eff1a5d4947f6fd71f2fd4fb7d1f
URL:
https://github.com/kamailio/kamailio/commit/219072f0ef43eff1a5d4947f6fd71f2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-01-18T17:40:42+01:00
siptrace: use formatted print for addresses inside trace_onreq_out()
---
Modified: src/modules/siptrace/siptrace.c
---
Diff:
https://github.com/kamailio/kamailio/commit/219072f0ef43eff1a5d4947f6fd71f2…
Patch:
https://github.com/kamailio/kamailio/commit/219072f0ef43eff1a5d4947f6fd71f2…
---
diff --git a/src/modules/siptrace/siptrace.c b/src/modules/siptrace/siptrace.c
index 3636a0929e..924c4f52e7 100644
--- a/src/modules/siptrace/siptrace.c
+++ b/src/modules/siptrace/siptrace.c
@@ -1093,12 +1093,16 @@ static void trace_onreq_out(struct cell *t, int type, struct
tmcb_params *ps)
sto.fromip = trace_local_ip;
} else {
if(dst == 0 || dst->send_sock == 0 || dst->send_sock->sock_str.s == 0) {
- siptrace_copy_proto(msg->rcv.proto, sto.fromip_buff);
- strcat(sto.fromip_buff, ip_addr2a(&msg->rcv.dst_ip));
- strcat(sto.fromip_buff, ":");
- strcat(sto.fromip_buff, int2str(msg->rcv.dst_port, NULL));
- sto.fromip.s = sto.fromip_buff;
- sto.fromip.len = strlen(sto.fromip_buff);
+ sto.fromip.len = snprintf(sto.fromip_buff, SIPTRACE_ADDR_MAX, "%s:%s:%d",
+ siptrace_proto_name(msg->rcv.proto),
+ ip_addr2a(&msg->rcv.dst_ip), (int)msg->rcv.dst_port);
+ if(sto.fromip.len<0 || sto.fromip.len>=SIPTRACE_ADDR_MAX) {
+ LM_ERR("failed to format toip buffer (%d)\n", sto.fromip.len);
+ sto.fromip.s = SIPTRACE_ANYADDR;
+ sto.fromip.len = SIPTRACE_ANYADDR_LEN;
+ } else {
+ sto.fromip.s = sto.fromip_buff;
+ }
} else {
sto.fromip = dst->send_sock->sock_str;
}
@@ -1109,13 +1113,16 @@ static void trace_onreq_out(struct cell *t, int type, struct
tmcb_params *ps)
sto.toip.len = SIPTRACE_ANYADDR_LEN;
} else {
su2ip_addr(&to_ip, &dst->to);
- siptrace_copy_proto(dst->proto, sto.toip_buff);
- strcat(sto.toip_buff, ip_addr2a(&to_ip));
- strcat(sto.toip_buff, ":");
- strcat(sto.toip_buff,
- int2str((unsigned long)su_getport(&dst->to), &len));
- sto.toip.s = sto.toip_buff;
- sto.toip.len = strlen(sto.toip_buff);
+ sto.toip.len = snprintf(sto.toip_buff, SIPTRACE_ADDR_MAX, "%s:%s:%d",
+ siptrace_proto_name(dst->proto),
+ ip_addr2a(&to_ip), (int)su_getport(&dst->to));
+ if(sto.toip.len<0 || sto.toip.len>=SIPTRACE_ADDR_MAX) {
+ LM_ERR("failed to format toip buffer (%d)\n", sto.toip.len);
+ sto.toip.s = SIPTRACE_ANYADDR;
+ sto.toip.len = SIPTRACE_ANYADDR_LEN;
+ } else {
+ sto.toip.s = sto.toip_buff;
+ }
}
sto.dir = "out";