Forráskód Böngészése

ims_registrar_pcscf: fix extraction of received host in save()

alexyosifov 5 éve
szülő
commit
2e11282502
1 módosított fájl, 2 hozzáadás és 7 törlés
  1. 2 7
      src/modules/ims_registrar_pcscf/save.c

+ 2 - 7
src/modules/ims_registrar_pcscf/save.c

@@ -128,6 +128,7 @@ static inline int update_contacts(struct sip_msg *req,struct sip_msg *rpl, udoma
 	char *alias_start, *p, *port_s, *proto_s;
 	char portbuf[5];
 	str alias_s;
+	char srcip[50];
 
 	pcscf_act_time();
 	local_time_now = time_now;
@@ -197,13 +198,7 @@ static inline int update_contacts(struct sip_msg *req,struct sip_msg *rpl, udoma
 						}
 					}
 				} else {
-					char* srcip = NULL;
-					if((srcip = pkg_malloc(50)) == NULL) {
-						LM_ERR("Error allocating memory for source IP address\n");
-						return -1;
-					}
-
-					ci.received_host.len = ip_addr2sbuf(&req->rcv.src_ip, srcip, 50);
+					ci.received_host.len = ip_addr2sbuf(&req->rcv.src_ip, srcip, sizeof(srcip));
 					ci.received_host.s = srcip;
 					ci.received_port = req->rcv.src_port;
 					ci.received_proto = req->rcv.proto;