Browse code

ims_registrar_pcscf: fix extraction of received host in save()

alexyosifov authored on 06/08/2020 19:13:51 • Aleksandar Yosifov committed on 12/08/2020 13:50:18
Showing 1 changed files
... ...
@@ -128,6 +128,7 @@ static inline int update_contacts(struct sip_msg *req,struct sip_msg *rpl, udoma
128 128
 	char *alias_start, *p, *port_s, *proto_s;
129 129
 	char portbuf[5];
130 130
 	str alias_s;
131
+	char srcip[50];
131 132
 
132 133
 	pcscf_act_time();
133 134
 	local_time_now = time_now;
... ...
@@ -197,13 +198,7 @@ static inline int update_contacts(struct sip_msg *req,struct sip_msg *rpl, udoma
197 198
 						}
198 199
 					}
199 200
 				} else {
200
-					char* srcip = NULL;
201
-					if((srcip = pkg_malloc(50)) == NULL) {
202
-						LM_ERR("Error allocating memory for source IP address\n");
203
-						return -1;
204
-					}
205
-
206
-					ci.received_host.len = ip_addr2sbuf(&req->rcv.src_ip, srcip, 50);
201
+					ci.received_host.len = ip_addr2sbuf(&req->rcv.src_ip, srcip, sizeof(srcip));
207 202
 					ci.received_host.s = srcip;
208 203
 					ci.received_port = req->rcv.src_port;
209 204
 					ci.received_proto = req->rcv.proto;